Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire analog waveform data using NIDAQmx & C++

Hello,

 

I am new to using the NI DAQ board and NIDAQmx.  I am trying to figure out the best way to capture analog DC voltage input values from my function generator on multiple channels, display them in real time, and also stream them to disk.  Could someone please provide some pointers on this?  The documentation seems to indicate that I need to capture the values as single samples but there are no examples.

 

Thanks,

 

-brian

0 Kudos
Message 1 of 7
(8,059 Views)

Hello Brianbat,

 

When you install DAQmx, you can add support for text base languages. If so, you should have a folder of examples for C++ using the DAQmx API. Navigate to All Programs>>National Instruments>>NI-DAQ>>Text Base Code Support>>ANSI C. Take a look at the example: Analog In>>Measure Voltage>>TDMS-Cont Acq-Int Clk for a continuous analog input acquisition and logging to a TDMS file.

 

Best Regards,

 

Alina M

Applications Engineering

National Instruments 

0 Kudos
Message 2 of 7
(8,036 Views)

Hello Alina M.

 

Thanks for responding.  Unfortunately I don't see an option to add Text-Based Code Support when installing NI-DAQmx.  What version is that option in?  I am currently using version 9.6.

 

Thanks,

 

-brian

0 Kudos
Message 3 of 7
(8,026 Views)

Hello Brianbat,

 

Go to the Control Panel>>Programs and Features, browse for National Instruments Software and click Uninstall or Change. Browse for DAQmx and click Modify. It will open the NI-DAQmx 9.6 driver wizard, expand NI DAQmx 9.6>>Application Development Support and you will see the options for text base support, change the ones you need. Take a look at KB How Do I Install Examples for Visual Basic, Visual C++, and Delphi with NI-DAQ?.

 

Best Regards,

 

Alina M

Applications Engineering

National Instruments

0 Kudos
Message 4 of 7
(8,014 Views)

Dear Alina,

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 satisfy both needs (if so wherefrom does this fault emerge)?

Thanks a lot for your helpfully replies in advance,

yours,

Mohammad

0 Kudos
Message 5 of 7
(7,549 Views)

Hi Harati,

 

The mentioned function should have a parameter to specify Terminal Configuration. The full function prototype is below:

DAQmxCreateAIVoltageChan (Task Handle, Physical Channel, Name to Assign to Channel, DAQmx_Val_RSE, Min value, Max Value, DAQmx_Val_Volts, Custom Scale Name);

 

So if i wanted to configure cDAQ1Mod1/ai0 channel for "MyTask" handle and I was using a RSE terminal configuration on a 0 - 5 Volt range, it would be configured like so:

 

DAQmxCreateAIVoltageChan (MyTask, cDAQ1Mod1/ai0, "", DAQmx_Val_RSE, 0, 5, DAQmx_Val_Volts, "");

 

Hope this helps

Gabriel M.
Product Marketing Engineer - Academic Courseware
National Instruments
Message 6 of 7
(7,525 Views)
Dear Gabriel, that was exactly the answer of my question and it is already solved, thanks that was really helpful, Mohammad
0 Kudos
Message 7 of 7
(7,379 Views)