07-01-2014 08:27 AM
Hello.
I am using the 9263 module in my 9178 cDAQ. I want to generate sinewaves. The problem I am facing is that most of the generated frequencies have jitter.
I read this page and it explains everything nice:
http://digital.ni.com/public.nsf/websearch/5782F1B396474BAF86256A1D00572D6E?OpenDocument but it still doesn't work for me.
When I want to generate a 400 Hz frequency at 100000 ksamples/second, everything works fine.
When I want to generate a 410, 390 or 420 Hz frequency at 100000 ksamples/second, everything works fine (I don't know why since the math are not giving integers).
If I want to generate a 401 Hz signal, then, according to the link above, I have to change the sampling rate but even if I do, it is still not working.
Furthermore, I do not understand the relation of the sine generator sampling rate and number of samples, with the DAQ sampling rate and number of samples.
Attached is my vi and two jitter images at 403 Hz.
Thanks.
07-01-2014 08:38 AM
HI vakost-
Do you need to be able to change the rates and generated data once started, or do you know that you want to consistently generate the same rate once you have started and until you stop?
If it is the latter, you do not need to execute a DAQmx Write with each iteration of the loop. You can simply choose the correct sample rate and then Write the waveform once, then Start and let the loop run. The data will automatically regenerate the same waveform repeatedly until you Stop. You probably still want to perform some error checking in the loop to make sure the task is running smoothly. Most users choose DAQmx Is Task Done (from the DAQmx Advanced Task Options palette) for this purpose.
The relationship between number of samples in the buffer and the sample rate seems confusing at first, but once you wrap your head around it, it can actually become quite simple. An example: let's say you want to generate a 100Hz sine wave, and you want a cycle of the sine wave to have 1000 sample points because you need that particular level of resolution between samples. If you need 100Hz sine wave on the output, that means you need 100 iterations of that sine wave buffer to be generated per second. Since there are 1000 samples per cycle of the wave, you need to use a sample/update rate of 100 * 1000 = 100,000 samples/second to achieve your 100Hz output wave. Hopefully this helps clear up any confusion.
07-01-2014 08:54 AM
07-08-2014 07:54 AM
Unfortunately, changing the sample rate isn't possible after a task has been started. In order to accomplish that you will need to do something as outlined in the following link (though there are significant side effects, primarily jitter). http://digital.ni.com/public.nsf/allkb/3B257B060840D86C8625750D0066F061
In terms of the unexpected signals you are seeing, let's step back for a moment. Right now we are thinking in the frequency domain, but this tends to make more sense in the time domain.
For things to work smoothly the period of the sampling rate needs to be a multiple of the period of the sample clock. For the 9178, you have sample clocks of 20 MHz, 10 MHz and 100 kHz. That corresponds to sample clock periods of 5e-8, 1e-7 and 1e-5 respectively. Since all the other rates you indicate are multiples of both 1e-7 and 1e-5, that's not an issue; you could use either the 100 kHz or 10 MHz sample clocks.
Unfortunately, the period of a 401Hz waveform is 249376.558e-8 and some change, which isn't an even multiple of any of those. As a result it's coercing the actual sampling rate, likely to 410 Hz-- the next multiple. Since you are specifying the number of points in each waveform, it plots 401 points and then is forced to fill the remaining 9 points with arbitrary data. Typically this is the last value given.
Also, as a side note, I wouldn't describe what you are seeing as jitter because it is still periodic in nature.
07-08-2014 12:18 PM
EDIT:
You actually can change the sample rate on the fly with many devices (yours included) as indicated here: http://zone.ni.com/reference/en-XX/help/370469AA-01/lvdaqmx/eseriesruntime/
There is an example here that should at least get you started: http://www.ni.com/example/29167/en/
07-09-2014 01:17 AM
Hello.
Thanks for your time. I actually sold the problem by setting "Automatic" Number of samples and "Integer number of cycles".
So, now it produces only the number of cycles I need per period.
I don't exactly understand the way it works and I want to dedicate some time to learn it.
Thanks again for your time.
Bill.