07-27-2010 06:29 AM
Hi all, I am using CVI 8.5 and DAQmx to read a voltage signal with a 6221 (37 pin). Since actual voltage spans up to 30V I have added a voltage divider before DAQ board so that output signal is 1/3 of actual signal. So far so good: I can read the input signal both with Max and my program without problems.
I then added a custom scale to multiply reading by 3, so that I can directly read in user units: at this point, the read value is clipped to 15.9 V for every voltage level higher than this; reading lower voltages gives correct results in user units. If I remove the custom scale I can read the full input voltage (0÷10V). What can be happening?
Instruction to set the custom scale
DAQmxCreateLinScale ("3x", 3.0, 0.0, DAQmx_Val_Volts, "Volts");
Instructions to prepare measurement:
DAQmxCreateTask ("", &misH);
DAQmxCreateAIVoltageChan (misH, channel, "", DAQmx_Val_Cfg_Default, -0.5, 10.0, DAQmx_Val_FromCustomScale, "3x");
DAQmxCfgSampClkTiming (misH, "", RATE, DAQmx_Val_Rising, DAQmx_Val_ContSamps, RATE / 10);
DAQmxRegisterEveryNSamplesEvent (misH, DAQmx_Val_Acquired_Into_Buffer, RATE / 10, 0, MisNI, NULL);
DAQmxSetReadAttribute (misH, DAQmx_Read_OverWrite, DAQmx_Val_OverwriteUnreadSamps);
DAQmxReadAnalogF64 (misH, RATE / 10, 1.0, DAQmx_Val_GroupByChannel, m, RATE / 10, &sRead, 0);
07-28-2010 04:26 AM
when you use a custom scale, you have to set the range of the acquisition (min val and max val in DAQmxCreateAIVoltageChan) in scaled units, so your max val should be 30 V.
07-28-2010 02:30 PM
Thanks for the info. I remember to have read something in this line in the past but is hasn't occurred to me when coding.
I will check this solution when going to startup the equipment in my customer's plant in the next weeks.
07-30-2010 04:31 AM
I understand that I must match channel configuration with actual signal limits, so I will update the code to use 30V, but I don't understand why measure reading was clipped in 15.9V and not in 10V.
Second question: could this error in configuration lead to damage in the board? I suppose the answer is no and the limits set in DAQmxCreateAIVoltageChan are only used for internal configuration and not as a hardware setup, but I would like to be assured about it.
07-31-2010 04:15 PM
The input limits specified by DAQmxCreateAIVoltageChan are used to control the board's programmable gain amplifier, which is why you saw clipping.
Your call to DAQmxCreateAIVoltageChan specifies input limits of [-0.5 "3x Volts" ... 10 "3x Volts"], which your "3x" custom scale converts to [-0.1667 V ... 3.333 V]. The NI 6221 has a programmable gain amplifier that is designed to support input ranges of [-10 V ... 10 V], [-5 V ... 5 V], [-1 V ... 1 V], and [-0.2 V ... 0.2 V]. DAQmx chooses the smallest range that can acquire a [-0.1667 V ... 3.333 V] signal without clipping, which is [-5 V ... 5 V]. Converting [-5 V ... 5 V] back to units of "3x Volts" gives you an input range of [-15 "3x Volts" ... 15 "3x Volts"], so you might reasonably expect the signal to clip at 15 V.
However, there is an additional complication: the input ranges on M Series devices are slightly wider to accomodate software calibration. Otherwise, a device's gain error might reduce the effective input range, and offset error would shift the ends of the effective input range. So the [-5 V ... 5 V] range on your NI 6221 might be more like [-5.2 V ... 5.3 V]. This is why the reading clipped at 15.9 V instead of 15 V.
As for your second question, connecting a 10 V signal to the NI 6221 when it is using a smaller input range will not damage the board.