Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Syncronizing AI and AO

I am using C++ with NIDAQ. I want to generate a waveform on an AO channel. With a specified amount of delay, read back the resultant waveform, and repeat (n) number of times. Anotherwords, I want to be able to syncronize these events....while collecting data. I am using an PCI MIO 16XE-10....browsing through the ni docs, I cannot find an example, that is not LabView.
bookieb
0 Kudos
Message 1 of 8
(3,629 Views)
Hello,

If you are looking for examples, you can find some C examples that installed with NI-DAQ in the following folder

C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C

If you are looking for documentation of C calls, you can find them in the following two places.

C:\Program Files\National Instruments\NI-DAQ\Docs\daqmxcfunc.chm
C:\Program Files\National Instruments\NI-DAQ\Docs\nidaqpc.chm

Also, several C examples exist on the website for CVI, and the DAQmx function calls will remain the same. Take a look here for an example that synchronizing input and output to using a shared clock.

J
ust let us know if you have any questions on these examples.

Best regards,
Justin T.
National Instruments
0 Kudos
Message 2 of 8
(3,629 Views)
Tiptop : thanks for your input. However I should have mentioned I am using C++. The CVI examples are a little help, but the function calls do not relate to the NiDaq calls I have available. What I am trying to do is generate a programmed square wave from a DAC device, defined by (EnergizeTime+InterpulseTime)*clockrate. I plan to trigger the ADC for data acquisition, when I start the DAC. I would like both to run at different rates, the DAC at 10,000 pts / sec and the ADC to run at 50,000 pts/sec. Sending a trigger to the ADC from the DAC is very slow, it would be nice to have the MIO card trigger the DAC without my program. Can this be done??
bookieb
0 Kudos
Message 3 of 8
(3,629 Views)
Tiptop : thanks for your input. However I should have mentioned I am using C++. The CVI examples are a little help, but the function calls do not relate to the NiDaq calls I have available. What I am trying to do is generate a programmed square wave from a DAC device, defined by (EnergizeTime+InterpulseTime)*clockrate. I plan to trigger the ADC for data acquisition, when I start the DAC. I would like both to run at different rates, the DAC at 10,000 pts / sec and the ADC to run at 50,000 pts/sec. Sending a trigger to the ADC from the DAC is very slow, it would be nice to have the MIO card trigger the DAC without my program. Can this be done??
bookieb
0 Kudos
Message 4 of 8
(3,629 Views)
Billb,

The answer is yes, you can hardware time an input and output to start at the same time and then run at different rates. However, the first thing to realize is that the acquisitions will run off of two different clocks, so if you plan on running this application over a long period of time, it would be best to use a thread for each acquisition, just in case the two clocks become offset.

The method of starting both at the same time with a single software call is to configure the output to start on a digital trigger. Then route the input�s convert clock to the output�s trigger line. Then whenever you start the analog input, the output will start at the same time.

As far as the CVI examples not relating to the NI-DAQ calls, this is n
ot the case. Both VisualC and CVI call the same dll in C. Unless, of course, you are using Measurement Studio 7.0 classes for C++ in the .net environment.

So feel free to ask any questions about which function calls you should use, but please let us know whether or not you are using Traditional DAQ or DAQmx, and what Development Environment you are using.

Best regards,

Justin T.
National Instruments
0 Kudos
Message 5 of 8
(3,629 Views)
Justin, thanks for your input. Yes, I have looked at some of the labview calls for some help. I am using MFC C++, I do have Measurement Studio installed as well, but primarily relying on NIDAQ function calls. I have looked at functions like Select_Signal to possibly help do this simultaneous actionm, but I find most of the explanations vague, that is unless you already know what you are doing. My issue is to start a receiving input at the same time I start my output. I am generating a square wave using DAC AO, and will get back an analog signal, both signals are being handled by an PCI-MIO-16XE card. Will Select_Signal be a good approach?? I noticed also, that the internal buffer of the MIO board is limited. My iterations of this o
peration can be up to 100 times, so I have to be able to transfer the buffer data to a local array. I also remember reading documentation about transfering buffer data while the transaction is in progress.
bookieb
0 Kudos
Message 6 of 8
(3,629 Views)
Hey Billb,

I have attached to this post a c file that contains the code for doing simultaneous AI and AO with the same clock. If you would like to have AI and AO run at different rates, then the best approach be to �configure the output to start on a digital trigger. Then route the input�s convert clock to the output�s trigger line. Then whenever you start the analog input, the output will start at the same time.�

Hopefully this will make more sense after looking over how select signal is used in the attached C file. Also, it would best to understand how the analog output using an external trigger example works.

Justin T.
National Instruments
0 Kudos
Message 7 of 8
(3,629 Views)
Hey Justin.....thanks for all of your input. I have managed to get the main part of the application working. It seems that I was on the right track all along, what I changed was, the call DAQ_Check to WFM_Check, and everything suddenly worked syncronously.
To tell you the truth, Select_Signal looked to have all the answers, but I couldn't get it to work. Always got a bad return code on at least one. Thought of double buffering, but found I don't need it, I am able to collect all of the data with one buffer.
Again thanks, and I appreciate your input and being a sounding board for me.
We are still thinking about trying to run the waveform(AO) and AI at different rates, with a delay between the two. Some people d
on't know when to quit.
THANK YOU VERY MUCH.
bookieb
0 Kudos
Message 8 of 8
(3,629 Views)