Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

variable rate waveform generation

With NI-DAQmx and C or C++ is it possible to generate a continuous analog waveform, and change the sample rate on the fly? I presume that it is, since there are two examples on the NI site:

http://zone.ni.com/devzone/cda/epd/p/id/4773
http://zone.ni.com/devzone/cda/epd/p/id/4775

These examples are for C# and Visual Basic, and a quick look didn't suggest to me how to do it in C or C++.

Thanks for any enlightenment!
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 1 of 6
(3,176 Views)
John,

Thank you for contacting National Instruments.  These examples do exhibit the functionality you need.  There are some examples that generate a continuous output to the analog output.  You acn use these to start with and add the functionality you need.  The basic idea is to create an array of the values you need to generate the sine wave frequency you need.  The sample clock actually stays the same, but it is used to determine deltaT, which is used in the calculation of the sine wave array.  The second example you reference creates this array with this line of code.

rVal(i) = amplitude * Math.Sin((2.0 * Math.PI) * frequency * (i * deltaT))

This will have to be adapted to C, but the concept is the same, and it creates enough samples to fill the onboard buffer.  Then they write it to the buffer while the task is running.

Hope this helps.

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 2 of 6
(3,151 Views)
OK- thanks for the info. All that C# and Visual Basic looks really different and I really didn't want to take a lot of time learning a language I'm not going to use!

It turns out I have understood the problem- the title of those examples suggests that it might be possible to change the clock.

Again, Thank you!
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 3 of 6
(3,149 Views)
John,

No problem.  I can see the confusion in the title.  Let us know if you are in need of any more help.  Thanks.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 4 of 6
(3,145 Views)

Hi John-

FYI, it is also possible to change the AO Sample Clock rate on the fly.  You can use the DAQmxSetSampClkRate(TaskHandle taskHandle, float64 data); property to accomplish this while an AO task is runningKeep in mind that this will not work for an AI task.

Hopefully this helps-

Tom W
National Instruments
Message 5 of 6
(3,128 Views)
Thanks, Tom. I missed that one.
John Weeks

WaveMetrics, Inc.
Phone (503) 620-3001
Fax (503) 620-6754
www.wavemetrics.com
0 Kudos
Message 6 of 6
(3,119 Views)