LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with NI-DAQ Example Code

Solved!
Go to solution

Hi. I've just started working with the NI ISB-6211. This is the first ACD i've ever used, so i'm farily new to this. I have quite a bit of knowledge in programming. After searching through the installation files I found some example C Code that runs in the command prompt. I've modified one quite a bit to get it to do what I want. My question is...

 

Now, i'm having some issues. I'm trying to get it to print a voltage reading into the command prompt. I've hooked it all up and i've used labview to make sure everything is working as it should (Which it does!). When I compile the C program and run it, instead of returning a voltage it just aquires points, and I really have no idea what these "points" are.

 

Here is the main part of the example code:

 

DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
			DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,1.0,10.0,DAQmx_Val_Volts,NULL));
			DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,1000));

			/*********************************************/
			// DAQmx Start Code
			/*********************************************/
			DAQmxErrChk (DAQmxStartTask(taskHandle));

			/*********************************************/
			// DAQmx Read Code
			/*********************************************/

			DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,&read,NULL));

			printf("Acquired %d points\n",read);


Error:

 And then it just moves down to the exit clause. Is there any documentation anywhere which tells me which DAQ command I need to use to print a continuously updating voltage read out? (Just as a decimal, like 5.21V for example).

 

Thank you all

John

 

0 Kudos
Message 1 of 3
(2,580 Views)
Solution
Accepted by topic author IMLJohn

John,

 

The data acquired by DAQmx is written into the array called 'data'.  The number of points DAQmx wrote into this array is stored in the variable 'read' which was passed in by reference.  To print the values returned, you'd need to loop over the 'data' array, and print each value.  See this help topic for an explanation of DAQmxReadAnalogF64.

 

Dan

0 Kudos
Message 2 of 3
(2,545 Views)

Yeah, I had just figured that out over my lunch break and got it working perfectly.

 

Thanks 🙂

0 Kudos
Message 3 of 3
(2,541 Views)