04-19-2007 03:55 PM
05-14-2008 04:06 PM
Hi GVanHorn!
I was reading your posting about the continuos waveform generation and your solution looks great. I need to develop a similar application where I'm planning to stream in sequence several waveforms arrays to an analog output. Every waveform takes about 30 minutes to play and before the generation time of the previous waveform is over, the buffer has to be filled out with the data for the new waveform generation, so this application sounds very close to yours. I'm wondering if you could share some of the code you use to acomplish this task so I can get new ideas. I've trying to found a good example in NI 's website but I haven't found anything similar . I'm developing my application using LabWindows/CVI 8.1.
Many thanks is advanced!
Giovanni G.
05-15-2008 05:40 PM
Hello Giovanni,
Just in case GVanHorn isn't available to reply (since his post is more than a year old). I just wanted to say that you may want to look at the CVI example program called "ContGen-IntClk.prj" as this should be a good starting point. You could easily modify this program to read data from a file each loop iteration and buffer the waveform that way. You'll want to generate continuously and turn off regeneration so you know if you keep the buffer full enough. I would recommend writing enough samples to the buffer each loop iteration so that you don't have to run the loop more than 10 times a second. For instance if you want to generate samples at a rate of 100 kHz then make sure that with each DAQmx Write call you buffer at least 10,000 samples from your file.
I hope this helps get you started, and have a great night!
Cheers,
05-19-2008 01:44 PM
Hi Brooks!
Thanks for your replay. As a matter of fact I've seen the example you mentioned but I'm a little bit confused on how to programmatically update the content of the buffer without affecting the current generation. Remember, since I'm planning to play a huge file I have to refresh the output buffer every once in a while, but at the same time a need to be sure that I'm not going to overwrite its content because that will interfere my current generation. I really don't know how to accomplish this. Any help would be appreciated. Thanks!
05-20-2008 08:29 AM - edited 05-20-2008 08:30 AM
Hello Giovanni,
The analog output uses a first in first out (FIFO) buffer. When you use another DAQmx Write VI to write more samples to the buffer they are added to the end rather than overwriting the samples that are currently in the buffer. The thing you need to look out for is running out of samples in the buffer before you add more. You can call a DAQmx Write whenever you like without interfering with the current generation because the buffer will output all of the previous samples before it begins using the ones you wrote most recently. I would recommend reading a chunk or points from your file each loop iteration and sending them to the DAQmx Write. A good target to aim for would be running the loop 10 times a second. With that in mind you should read and write enough samples to sustain 0.1 seconds of generation at the rate you've selected.
Cheers,
06-18-2008 02:09 PM
Hi, I'm posting this message again because my situation has changed a little bit. Now I need to play a sequence of different waveforms. All the waveforms have different parameters like size, sampling rate, amplitude, etc. I have a script file (text file) that holds the parameters necessary for the AO generation. This is the logic:
Read sequence waveforms from text file
Read data waveform from data file
Read AO conditions: start time, end time, sample rate, channel
Call Generate AO
Configure the task: timing, number of samples, etc accordingly
Start task
Is this task done?
Is this the last AO generation?
yes: End AO generation
no : go to the top of the loop
I’m kind of lost about how to accomplish this since every AO generation is different. I'm having problems while trying to recall the next AO generation. I do not know how to synchronize these two events. Do you have any sample code or suggestions?
(I'm using Labwindows CVI 8.2 and DAQmx driver)
Thanks a lot.
06-19-2008 04:00 PM
Hello giogonza,
In order to change task parameters such as the rate you need to stop the task. In your current structure you will have to stop the task, configure the next task, and then restart the task. If you take this approach then it will be difficult to synchronize the tasks because there will be some software timing in between waveforms, but you could probably get this within a few ms.
If you require better timing then this then you'll need to configure your waveforms to be output with the same channel parameters. For instance, if you have 2 waveforms that need to be output, one at 1 kHz and the other at 2 kHz, you could change your first waveform to have duplicate points (or interpolate points) so that it had twice as many and then could be output at 2 kHz. Then you could turn off regeneration for your output channel and just buffer both waveforms without changing any of the channel parameters. The second method would be the cleanest solution, but you'll need to modify your waveform data to have a consistent update rate.
Cheers,