04-14-2008 04:49 AM
04-18-2008 12:22 AM
04-18-2008 04:54 PM
since totalNumberOfBytes has no meaning in continuous mode.
Hopefully this helps-
04-28-2008 04:20 AM
04-28-2008 09:21 AM
Hi Rick-
Sorry about that- I haven't updated the MHDDK page in a while and since the last update there has been a new example added. I have attached aiex4.cpp here. You will also need the DMA library, available from the MHDDK download page, to run this example.
Thanks-
08-03-2008 10:10 PM
Hi Tom,
Thank you for the code file you sent to me. I have met a new question about aiGetScalingCoefficients() function. The comment for aiGetScalingCoefficients() is :
//
// aiGetScalingCoefficients --
//
// modeIdx
// 0 -> default
//
// intervalIdx
// 0 -> +/- 10V
// 1 -> +/- 5V
// 2 -> +/- 2V
// 3 -> +/- 1V
// 4 -> +/- 500mV
// 5 -> +/- 200mV
// 6 -> +/- 100mV
//
// channel
// ignored - all channels use the same ADC
//
I do not understand why the "channel" parameter is ignored. If all the channels have the same AI range, it is OK to ignore this parameter. However, if different channels apply different analog input gain value, how can I distinguish the channels without the "channel" parameter?
I am afraid I have some misunderstanding on this function. Could you please make an explanation for me?
Thank you in advance 🙂
Regards,
Rick
MSP
08-04-2008 09:30 AM
Hi Rick-
The aiGetScalingCoefficients() function does not require a channel parameter because there is only one set of scaling coefficients for each range (because there is only one ADC on the device). In order to scale channels of varying ranges, you would need to call aiGetScalingCoefficients() multiple times and use different intervalIdx values. In this way, you can retrieve scaling coefficients for the various ranges on the device as needed. Any channel configured for +-10V operation would need to be scaled relative to intervalIdx = 0, any channel at +-5V would need to be scaled relative to intervalIdx = 1, etc.
08-13-2008 08:23 PM
Hi Tom,
Sorry to interrupt you again 🙂
In your last reply on this thread, you said "In order to scale channels of varying ranges, you would need to call aiGetScalingCoefficients() multiple times and use different intervalIdx values." But I'm not clear about how to call aiGetScalingCoefficients() multiple times.
If I put aiGetScalingCoefficients()s after aiClearFifo (board) and before aiArm (board, kFalse) (similar to the code sample 1), there will be always ONE range for all the channels, whatever the range value is. The result of the AI scan is also incorrect. I'm afraid this is not the "multiple times".
I wonder whether I can put aiGetScalingCoefficients() before aiPolynomialScaler (&value, &scaled, &scale) (which means set the range before read the value). This can satisfy the "multiple" demand. But when I run the program, the Windows unfortunately crashed...
So, could you please explain a little clear about how to call aiGetScalingCoefficients() multiple times? Where is the correct position to place this function at?
Thank you for your support during my project!
Rick
MSP
08-20-2008 04:44 PM - edited 08-20-2008 04:45 PM
Hi Rick-
aiGetScalingCoefficients() only retrieves scaling coefficients from the device EEPROM for a single AI range. So, in order to call it twice you would need two instances of tScalingCoefficients and would call aiGetScalingCoefficients() twice, passing different range offset values and tScalingCoefficients references each time.
To actually apply the two different sets of scaling coefficients you would need to modify aiPolynomialScaler(). Right now, it operates on the raw data sequentially and applies the same scaling coefficients to all data. You would need to modify it to apply different scaling coefficients based on which channel index you were into your raw data. The raw data is interleaved per channel, which means that each sequential point in the rawData array would correspond to a different channel's data.