06-26-2019 03:50 PM
I am trying to output a sinusoidal analog output waveform using an analog output. I am using the regeneration function.
This works very well. However I need to change the frequency of my waveform. I can do it however when I generate a new waveform with the new frequency I need to adjust the samples to generate the waveform so I start and stop at the same point so it generates the correct waveform.
Second waveform. Note that more samples are needed so waveform starts and stops at same point. This is needed for continuous regeneration
The problem I am having is the buffer gets set on my initial waveform( i.e. 1000 points) when I write a new waveform (1136 points) the buffer isn't big enough to accommodate the new waveform. To resize the buffer I need to start and stop my task which I don't want to do (creates other problems I won't go into). So my question is can I create a buffer that is large say 2000 points. Then give it a waveform of lets say 1000 points. Will the regeneration mode only loop through the 1000 points or will it loop through the entire buffer of 2000 points? I would try this but the customer has the hardware at a remote location.
06-26-2019 04:40 PM
06-26-2019 05:06 PM
1. I was just in a thread where it *appeared* that regeneration occurred only over the 128 *written* samples in a task with a buffer size of 1000. It was a Finite Sampling task however, so perhaps that's the key difference?
2. I don't think you can resize the buffer while the task continues running.
3. Another sneaky trick you might consider is this: on most DAQ boards you actually *can* change the sample rate of an AO task on-the-fly without stopping it. You won't get infinite granularity for your waveform frequencies, but you might get enough.
Example: suppose you put 100 samples in the buffer to define a sine wave cycle. You want a ~200 Hz sine wave to start. So you set a sample rate of 200*100 = 20 kHz.
Dunno your board, but I'll assume newer X-series with a 100 MHz master timebase. So the sample clock is made by dividing the 100 MHz clock by 5000. Here's where the granularity comes in. The available sample rates will be integer divisors of 100 MHz. So to speed up your sine wave by the smallest available increment, you'd need a divisor of 4999. This sets a sample rate of (100 MHz / 4999) = 20.004 kHz and a sine wave frequency of (20.004kHz / 100) = 200.04 Hz. That seems like a pretty small quantization effect. It'll get bigger for higher waveform frequencies.