07-05-2005 10:15 AM
07-06-2005 03:19 PM
07-06-2005 11:04 PM
Hello Lorne,
I have a very basic question, how do I adjust the output waveform frequency from the formula and DAQmxWriteAnalogF64:
(1)for(;i<1000;i++) data[i] = 9.95*sin((double)i*2.0*PI/1000.0);
(2)DAQmxWriteAnalogF64(taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL)
I notice if I change the 1000 in data[i] = 9.95*sin((double)i*2.0*PI/1000.0) to 100, 10 respectively, the output freq change from 1Hz, 10Hz then 100Hz, but the waveform becomes no longer sinusoidal but with sharp square steps. I know this is no a proper way to change the output frequency so I need your advice on what to do?
Thank you!
07-07-2005 09:12 AM
07-08-2005 04:38 AM
Hello Lorne,
I can change the output freq if I change the "10" to "100" and get a smooth sinusoidal wfm,
----------
for(;i<10;i++) data[i] = 9.95*sin((double)i*2.0*PI/10.0);
----------
DAQmxWriteAnalogF64(taskHandle,10,0,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL)
----------
But how can I change the wfm output freq on-the-fly by specifying
the beginning freq, ie. 500Hz;
the ending freq ie. 1500Hz;
the freq step ie. 20Hz;
Within a period of, say, 2 seconds?
I try to change something called Sample Clock Timebase Divisor, with can do the similar thing of varying output wfm freq, but I cannot adjust it with the program is running? Is this another approach?
thank you!
07-08-2005 11:42 AM
07-09-2005 05:50 AM - edited 07-09-2005 05:50 AM
hi Lorne,
I managed to fulfill my objective please have a look at the attached c file. And I discovered something strange as I limit the freq shifting process within 2000 msec:
If I set the min freq 500Hz, max freq 1500Hz, freq step 20Hz, it finish shifting within 2 sec;
if I changed max freq to 5000Hz with the rest 2 parameters unchanged, it takes longer than 2 sec to complete shifting; and if i set Sleep(1) inside the FOR loop, it is the same, taking more than 2 sec to complete the shift!? If I set Sleep(0) then there is no delay, I wonder what had happened to the Sleep()??
Can you help? Thank you.
Regards
Rolly
Message Edited by Rolly on 07-09-2005 07:51 PM
07-11-2005 11:59 AM
08-03-2005 04:42 PM
Dear Lorne,
I have a question related to your conversation with Rollie. Maybe you, or someone, can help me. I also want to change my output waveforms on the fly. I want to continuously cycle through one waveform, and then do a DAQmxWrite to switch to another waveform, also continuously cycled. But I need to carefully control the signal continuity and slope at the transition point. I can make sure that the digital signal at the tail of one output buffer lines up with the digital signal at the head of the next. But when I do the DAQmxWrite in the middle of a continuously cycling analog output, will the output complete a pass through the one buffer before switching to the next, or will it switch over in the middle of the buffer, as soon as the DAQmxWrite executes, causing a discontinuity in the analog signal? Is my question clear?
Josh Moses
08-04-2005 03:55 PM
Hello Josh,
The DAQmx Write function will finish writing the old buffer before writing the new one. If the endpoints of your buffers match up, you shouldn't see any discontinuity.
Regards,
Sean C.