04-26-2010 03:06 PM
I want to use an AO channel to generate a waveform, for instance a sine wave. There is a nice example provided in the docs that shows this.
I want to be able to synchronize the analog input on an input channel to the waveform generation. In other words, I want to be able to get the code to act like there is a trigger - when the generation next reaches the start of the buffer, I want the analog input to start, acquire its alloted number of readings, and then stop. I need to be able to do this repeatedly - while the waveform generation continues, from time to time I need to be able to start a data acquisition, have the data acq wait until the start of the buffer, and then run.
I assume there is a smart way to do this, but I have not found it.
The thread "Single-shot waveform and 2 concurrent voltage measurement without hardware trigger " has a similar idea using master/slave tasks, but I need continuous generation and randomly initiated measurement. This thread seems to require the slave task (acquisition) to be started before the master task (generation), which I don't think would work for me.
I'm using NIDAQmx, VB6 and a USB-6212 but am likely to use other hardware as well.
Thanks,
Van
04-28-2010 10:02 AM
Hi Van,
As long as you are performing these tasks on the same card, the measurements will be correlated because they all share a common timebase. What you will have to do is create your AO task to run continuously then create a retriggerable AI task. To create a retriggerable AI task, you will have to create a retriggerable finite pulse train output from your counters then use this as the sample clock for your AI task. You can just run the AO task seperately.
04-30-2010 05:45 PM
Thanks Jim. Is there any sample code for this kind of application? I've not used a sample clock before.
One thing I still don't understand in your descrption - what "triggers" the retriggerable pulse train such that AI starts at the right time (phase) relative to the AO?
Van
05-03-2010 03:26 PM
Hi Van,
When do you want to take your acquisition? From your description, it sounds like you want your AO to run continuously then take a finite AI acquisition multiple times throughout the program. When do you want to trigger the AI? There are no specific examples that do what you want, but you can take a look at the VB6 examples that are attached. If you just want to perform AI and AO at the same time, you can just combine the AI and AO examples, then perform some post processing. To create a retriggerable AI task, you will have to:
1. Create a continuous AI task
2. Set your AI task to use an external clock
3. Create a retriggerable finite pulse train
4. Use the finite pulse train as the sample clock for the AI task.
The example below will show you how to set up a retriggerable finite pulse generation:
Retriggerable Finite PulseTrain Generation with Measurement Studio for Visual Basic
02-15-2011 04:40 AM
Hi Jim,
I hope you are still around to continue this thread... It's been a while.
02-16-2011 04:03 PM
Van,
It'll take some time for me to get a good grasp of all the above, but to simplify a bit, are you able to read any of the data that is being used to register the callback? In other words, are the conditions you are using to trigger the callback changing or being set as you expect? Also, have you been able to get simple callbacks to work with functions of this type before? We might want to work on simply to a basic program checking that value or working on a callback before we try to find out the issue in your program as a whole.
Timothy
02-16-2011 05:14 PM - edited 02-16-2011 05:19 PM
Hi Van,
You might be doing this elsewhere in your program, but you haven't included the part where you start the CO Task with DAQmxStartTask(tsk_Ctr0). This should occur after the AI and AO tasks have started so they are armed and ready to receive the external sample clock. If you don't start the CO task this would explain why no samples are ever available.
Also, while it shouldn't cause any problems, setting the counter output to retriggerable doesn't do anything in this case since the task is not being triggered by anything and is configured to run continuously. The comment for that section of code is misleading since you are configuring a continuous CO task rather than a retriggerable finite CO task. Actually, if you're not using the counter for its retriggerable functionality, you could just instead share the AI or AO sample clock directly.
Best Regards,
02-18-2011 01:08 PM
Hi John and Timothy,
Thanks for your feedback. Indeed, I was not starting the task! However, rather than try to continue down that path using the counter, I've taken your suggestion of not using the counter at all. I'm not sure why I was told to go down that path, perhaps I had not explained myself well enough, or perhaps the realization that the equivalent functionality could be achieved by just doing continuous AI and then ignoring all the data I don't need, rather than trying to start AI at random times when needing data.
At this point, I have removed the counter stuff and seem to have a working demo program that does simultaneous AO and AI, and uses the callbacks to collect the data.
Van