Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to perform 2 AOs and 1 AI simultaneously in C/C++ programming

In my lab, I use the first shaker (AO 1) to generate vibration of a beam by sending it some waveform signal. At the same time, I use the same signal data for the first shaker (as reference signal), together with the feedback from a sensor (AI), to calculate (by my neural network program) to get some other data, and send the data to the second shaker (AO 2) to cancel the beam vibration.

I'm new to DAQ programming. I want to use Visual C++ 6.0 to do data acquisiton on DAQ card. All the AI and AOs in my lab must be run simultaneously

I'm not sure how to set up the relationship among the two AOs and one AI to control them in my lab. If you can throw some light on that I would apprciate it.

T
hank you very much!

Marlon
0 Kudos
Message 1 of 12
(5,781 Views)
Hello Marlin,

The following Example Program demonstrates how to achieve Simultaneous AI/AO with Visual C++:
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3E72F56A4E034080020E74861&p_node=DZ52337&p_source=External
0 Kudos
Message 2 of 12
(5,781 Views)
Thank you very much, Sean. However, I can't find the include files, e.g. userint.h and analysis.h, etc, on my computer. I only have NI-DAQ 7.3. I guess I need "LabWindows/CVI Full Development System 5.0", right? How can I get it? Is there any other ways to solve this problem in MS Visual C++?
0 Kudos
Message 3 of 12
(5,781 Views)
Marlon,

Those include files come with CVI. If you download an evaluation version of CVI, you should be able to use that example program.
You can get an evaluation copy of CVI at:
http://digital.ni.com/demo.nsf/websearch/531EA137A674B28786256BC100663B5C?OpenDocument&node=11107_US

Alternatively, you could take a look at the ANSI C examples that ship with NI-DAQ. These are example DAQ programs that use either DAQmx or Traditional DAQ. However, these examples only show AI or AO, not simultaneous AI/AO. They can be found at C:\Program Files\National Instruments\NI-DAQ\Examples.

I hope this helps,

Sean C.
0 Kudos
Message 4 of 12
(5,781 Views)
Hi, Sean:

Thank you very much! I'll try it.

BTW, do you know how to dynamically Adjust Frequency and Amplitude for a Generated Sine Wave in C/C++? This is also a part of my project: I need to dynamically generate a sine wave voltage signal for the second shaker by some calculation using the data from an analog input and another signal (as you can see in my original question).

Your help is so appreciated.

Marlon
0 Kudos
Message 5 of 12
(5,781 Views)
Hi Marlon,

You could use the standard C++ functions to create your sine wave. The board will output an array of numbers; you just need that array to be the voltages of a sine wave.

for(int i = 0;i<1000;i++)
data[i] = 9.95*sin((double i*2.0*PI/1000.0);

The above code will generate an array of 1000 data points that is one cycle of a sine wave. You can adjust the constants and number of array points to get the array to look how you need it to.

Thanks,
Sal
0 Kudos
Message 6 of 12
(5,781 Views)
Just to be clear, I'd like to point out that there is both an ANSI C and a C++ API to DAQmx. These are distinct APIs. Though the C API could be used in C++, the C++ API is object-oriented rather than a flat list of functions. If you are using the C++ language (rather than a C++ compiler to compile C, for example), you should find the C++ API more natural.

Another important difference is that the DAQmx C++ API requires National Instruments Measurement Studio and only works with Visual Studio .NET 2003 or later. The C API does not have these restrictions. Since you're using Visual Studio 6.0, the C API is probably your best choice unless you plan on upgrading to Visual Studio .NET 2003.

Just a word about Meas
urement Studio, if you're not already familiar with it. Measurement Studio augments Microsoft Visual Studio specifically for measurement and automation. Among other things, Measurement Studio gives you environment integration like project wizards and tool windows, user interface controls, and the same NI libraries you find in other languages, such as advanced analysis and DataSocket. For DAQmx, GPIB, and VISA, Measurement Studio allows you to do DAQmx code generation in C++, C# and VB .NET. You can find out more at http://www.ni.com/mstudio

Chris W
.NET/C++ DAQmx Team
0 Kudos
Message 7 of 12
(5,781 Views)
Thank you all. Since I'm using Visual Studio 6.0, the C API is probably my best choice. Moreover, besides NI-DAQ 7.3, I guess I need LabWindows/CVI or LabView, right? Which one is better? Do I need both of them?

Marlon
0 Kudos
Message 8 of 12
(5,781 Views)
Marlon,

Since you are using Visual Studion 6.0, you would want to purchase Measurement Studio to make your text based programming easier. You could also purchase LabWindows/CVI. CVI is the NI C programming interface (you wouldn't need Visual Studio). It has several features to automate DAQ programming and many example programs.

LabVIEW is our graphical programming language interface that uses block diagrams to create your programs. If you are planning on using the text based visual C++, I would still recommend downloading the evaluation version of LabVIEW to see how easy it is to use. LabVIEW has many features that make DAQ programming very easy.
0 Kudos
Message 9 of 12
(5,781 Views)
Marlon:

LabVIEW, LabWindows/CVI, and Measurement Studio are designed to be symmetric offerings of NI technology for different programming languages. LabWindows/CVI users program in ANSI C, Measurement Studio users program in .NET or C++, and LabVIEW users program in a graphical programming language. Though you can mix these products (call CVI DLLs from LabVIEW, for example), it's most commonly the case that you only buy the product that corresponds to the programming language you want to work in. If you're collaborating with someone who prefers a different programming language, for example, then you may be interested in purchasing more than one of the products.

The idea is that if yo
u already know C and want to work in C, then you can buy LabWindows/CVI and program in C, rather than having to learn a different programming language to use NI products. We want to give you as many options as possible.

As Salvador suggested, you may want to check out all three products before making a decision. In fact, I would recommend speaking to an NI sales engineer to help you make a decision. S/He should be able help you find the product that's best for your particular situation. You can contact sales online by going to http://www.ni.com and choosing "Contact NI" in the horizontal bar at the top of page.

Hope this helps,

Chris W
.NET/C++ DAQmx R&D Team
0 Kudos
Message 10 of 12
(5,781 Views)