Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

read analog signal 0 - 10 volts from NI6123

Solved!
Go to solution

I am trying to read analog signal from NI 6123. The analog signal range is 0 to 10 volts. It works well when the signal voltage is from 0 to 5v (0 ~ 32767). But when the signal is 5 to 10 volts, the read value is always 32767. I also tried different read function: DAQmxReadBinaryI32, DAQmxReadBinaryU16, DAQmxReadBinaryU32. The value is the same as DAQmxReadBinaryI16. My OS is windows vista. Below is part of my codes.

 

**************************************************************************************************************************************************************************

// Create analog data task //

DAQmxErrChk (DAQmxCreateTask("",&datHandler));

DAQmxErrChk (DAQmxCreateAIVoltageChan(datHandler,"Dev1/ai0:7","",DAQmx_Val_Cfg_Default,-10,10,DAQmx_Val_Volts,NULL));

 

DAQmxErrChk (DAQmxCfgSampClkTiming(datHandler,"",RATE,DAQmx_Val_Rising,DAQmx_Val_ContSamps,RATE*MAXLAS));

DAQmxErrChk (GetTerminalNameWithDevPrefix(datHandler,"ai/SampleClock",trigName));

 

 

// Create counter task //

DAQmxErrChk (DAQmxCreateTask("",&ctrHandler));

DAQmxErrChk (DAQmxCreateCICountEdgesChan(ctrHandler,"Dev1/ctr1","",DAQmx_Val_Rising,0,DAQmx_Val_ExtControlled));

 

DAQmxErrChk (DAQmxCfgSampClkTiming(ctrHandler,trigName,RATE,DAQmx_Val_Rising,DAQmx_Val_ContSamps,RATE));

 

DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(datHandler,DAQmx_Val_Acquired_Into_Buffer,RATE,0,EveryNCallback,NULL));

DAQmxErrChk (DAQmxRegisterDoneEvent(datHandler,0,DoneCallback,NULL));

 

 

// start task //

DAQmxErrChk (DAQmxStartTask(ctrHandler));

DAQmxErrChk (DAQmxStartTask(datHandler));

 

 

In call back function:

   DAQmxErrChk (DAQmxReadBinaryI16 (datHandler,RATE,3.0,DAQmx_Val_GroupByChannel,data.laser,RATE*MAXLAS,&(data.dataRead),NULL));

   DAQmxErrChk (DAQmxReadCounterU32(ctrHandler,RATE,3.0,data.counter,RATE,&(data.ctrRead),NULL));

   // write data into file //

  

   data.cfile.Write(data.counter,sizeof(int32)*RATE);

   data.cfile.Write(data.laser,sizeof(int16)*RATE*MAXLAS);

**************************************************************************************************************************************************************************

 

Thanks in advance

0 Kudos
Message 1 of 2
(2,969 Views)
Solution
Accepted by topic author lwu

To make sure that your device is working properly I would first recommend to test the analog input in Measurement and Automation Explorer (MAX).  You can test your device by right clicking it in the configuration tree and selecting test panels.  See if you the signal acquired is 0-10V like you are expecting.  The next step would be to try one of the example programs that perform an analog input task.  These examples can be found in Start>>Programs>>National Instruments>>NI-DAQ>>Text Based Code Support.  Try an example that performs a continuous analog input and reads in doubles (instead of unscaled binary data).

 

Your program looks good initially so I could not find anything that stood out.  One thing to check though is if your function generator (or signal source) is expecting a 50ohm or high impedance.  This could cause signal reflections and cause the device to possibly read a voltage of half the desired value.

Regards,
Jordan F
National Instruments
0 Kudos
Message 2 of 2
(2,949 Views)