Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Data acquisition with USB-6008 using C++

Solved!
Go to solution

Hi,

 

I'm trying to use the USB-6008 to collect analog data without using Labview, since I can't afford the lincence. I searched in the C++ examples provided with the product and found "Simple Analog Input Example".

 

The compiler I use is codeblocks instead of visual studio (again for monetary reasons). The code seems to works since when I run it with the USB-6008 connected, it writes "Acquired 1000 points".

 

I have 3 questions related to the use of this code:

 

1. Where are these 1000 points stocked?

2. How can I modify the code to specify the acquisition time and acquisition frequency?

3. How can I modify this code to sample points simultenously with the 8 analog entries?

 

Thank you for your help,

I'll try to add any precision if necessary.

 

Albany

0 Kudos
Message 1 of 5
(6,046 Views)
Solution
Accepted by topic author Albany
Your questions are answered in the help for c programmers.

The 1000 points are in the floating point array called 'data'.

The sample rate is set with the timing function.

The number of points read is set with the read function.

The channels to read are set with the define channel function. To read multiple channels, use syntax like Dev 1/ai0:3 for the first 4 channels.
0 Kudos
Message 2 of 5
(6,040 Views)

Now that was a quick answer, thanks a lot.

 

I'll check out the C programmer help documentation.

0 Kudos
Message 3 of 5
(6,032 Views)

Dear Dennis,

i wrote a program in VC++ which acquires some analog voltage channels using NIDAQmx. By means of the "DAQmxCreateAIVoltageChan()" function it works properly, but I've faced a question:

When I measure a sine wave as a input channel whith diffrential terminals (pins) on NI-Device, there is no problem but if I connect the input signal in single ended form (connect input signal to each single terminal and connect GND of NI-Device and Signal generator together), there is a irrigular and alternative offset (DC value) in aqcuiered data that shows there is an error in connection of GND's. (I'm sure about function generators)

Is there any specific function to assign exactly that input data should be measured in differential or single ended form? I mean, should I write seperate codes in C++, if I want to measure input signal in both forms of differential and single ended or does the mentioned function ( DAQmxCreateAIVoltageChan() ) satisfy both needs (if so wherefrom does this fault emerge)?

Thanks a lot the knight of ni 😉 ,

yours,

Mohammad

0 Kudos
Message 4 of 5
(5,935 Views)

Harati,

 

There is a parameter for the DAQmxCreateAIVoltageChannel Function called terminalConfig. This can be found in the C Reference Help under NI-DAQmx C Functions>>Channel Configuration/Creation>>Create Analog Inpupt Channels>>DAQmxCreateAIVoltageChan. Possible values for this parameter are listed in the help file. Post again if you have further questions.

Robert B
RF Product Support Engineer
National Instruments
0 Kudos
Message 5 of 5
(5,911 Views)