I am using USB 6251 to generate a ramp and simultaneouosly aquire signals from the 16 channels.I am confused regarding the rates to be used with the sampling clock, read and write as depicted in the figure below (A,B,C,D). I am queuing the data as well for further analysis.
I see that ratio's A/C whould be equal to B/D for proper synchronised display and operation. The max sampling rate of 6251 as indicated in its data sheet is 1 MS/s; with the rates mentioned crashes the prgram in about 1-2 hours. But if I reduce B & D to half its present value I am able to run it with all 16 channels aquisition for about 10 hours then the program crashes with the message
onboard device memory overflow. because of system and bus/bandwidth limitations, the driver could not read data
from the device fast enough to keep up with the device output rate.
reduce your sample rate, or reduce the number of programs your computer is executing concurrently."
1.please tell me what the rates A,B,C,D mean , particularly A & B and what would be ideal values for it.
2. reg frequency control of the sawtooth which i generate, i see that it can be controlled by A/C ratio as well, is it better to control it using this ratio or use the vi. parameter, i can unserstand that it would mean difference in number of sample points constituting the wave but still;.
3. 6251 uses multiplexed aquisition, so does it mean that channels in the beginning ( i.e 0&1) would have more noise in it because it would be the time when the points written would switch causing a distortion.
Rate A is updating rate of analog outputs, meaning the rate at which analog outputs take new data from the buffer and updates output
Rate B is sampling rate of analog inputs, meaning the rate at which analog inputs samples data.
For C is more complicating - in sawtooth wave you are setting frequency in samples/period, and with samples you are setting number of samples in the array you are outputing. For example if you have frequency of 500 samples/period and outputing 1000 samples, you will output 2 periods of sawtooth wave, or if you have frequency of 500 samples/period and outputing only 250 samples, you will always output only first half of the period
And D is number of samples you read at once from each of the channels at the sampling rate you specified for the analog inputs (rate B)
Lets have a look at few examples:
Our sampling rate of analog input is 1000 samples/s, and we read 100 samples at once. Read block will wait 100ms to gather all 100 samples and then output them. (because of the 1k samples/s rate analog input acquire one sample each 1ms)
Our update rate of analog output is 1000 samples/s, we specify frequency of Sawtooth wave is 500 samples per period and we send 2000 samples to DAQmx write.
So for one period of sawtooth wave we need 500 samples, and we update output at 1000 samples per second, meaning to output one period we need 500ms, so the output frequency of sawtooth wave will be 2Hz. And because we write into buffer 2000 samples, update them with rate of 1000 samples/s we will be updating output for 2 seconds (with Regeneration not allowed- if we allow Regeneration, after 2 seconds we will start updating from the beginning)
So the frequency of generated sawtooth is defined by: output frequency = update rate / (frequency in samples per period)
ni.com: "Typically, the digitizer is the most expensive part of a data acquisition system. By multiplexing, you can sequentially route a number of signals into a single digitizer, thus achieving a cost-effective way to greatly expand the signal count of your system. Multiplexing is necessary for any high-channel-count application."
So multiplexing does not provide different levels of noise to different channels, it is only used to be able to use only one ADC converter and multiple analog input channels.
Sampling rate of digitizer is the speed at which the digitizer’s ADC (not analog input itself) converts the input signal, after the signal has passed through the analog input path, to digital values. There is hardware limitation of this rate, for USB 6251 is 1MS/s per ADC (for multiple channels). This is the sampling rate mentioned in the specification.
But, if we use multiple channels, we share the capability of ADC rate of 1MS/s - meaning if we use 15 channels, as in your program, we can sample with maximum of 1MS/s / 15 chanels equals to 66.7kS/s per channel. In your program AI sampling rate is set to 100kS/s, which is not achieveble.
I hope that I answered your question. Still I have some proposals to make your code better:
- If you want to start AI and AO at the same time, you should examine Multi-Functio-Synch AI-AO in the example finder. Then it is no need to use occurances
- You can put DAQ write outside the loop and regeneration to true - this way you will write the signal into the buffer, and after that AO will continiously produce desired frequency. There is an example called Cont Gen Voltage Wfm-Int Clk. An if you want to change frequency of the
- Is queue used to communicate with other VI? If it does it is recommended to release queue at the end.
If you have any questions about rates or improving your code fell free to ask.
Thank you very much for your reply gregor,
the multi function sync AI-ao which you mentioned is not for constant updating of ao voltage, for updating the ao voltage I have to stop and then re run the program , to have a dynamic way of updating the waveform I use the "do not regenerate " option and the occurrence. I am still searching for a better alternative to this.
The queue is used in another loop which I didn't show here where I release it.
I want to have the program such that I read a single period response of the sawtooth voltage, with control in frequency as well, I am getting confused reg this.
What you wish to accomplish is quite reasonable, however to provide you wish an efficient coding avenue could you please provide me with the following information:
a) Your maximum signal frequency output?
b) The maximum tolerable latency between cycle outputs of the sawtooth waveform after altering the signal frequency?
Thanks for your reply.
1. My intended Max frequency output is 200 Hz's.
2. The maximum tolerable latency between cycle outputs of the sawtooth waveform after altering the signal frequency.Actually we haven't decided on the latency yet, so whichever is least possible or suitable will do.