11-19-2015 05:44 PM
Hi,
Apologies if this has been asked before, but I've done a fair bit of searching and can't find anything that addresses the issue.
I have a compact daq system, and amongst other things, I have 3 analogue waveforms I want to output on 3 separate channels, for example, one with a frequency of 7 Hz, one at 6 Hz and one at 5 Hz, and I want all three waveform to repeat over a finite number of samples.
If I was just doing this on one channel, I would set daqmx to output one channel, n-samples in finite sample mode, set the number of samples at the total number I want to output, and provide one full period of the waveform in the 'write' function. When the full wave has been outputted, the buffer then loops back to the beginning and keeps doing this until my total number of samples has been written. All works fine up to here....
But... when I want to do this with three waveforms of different frequencies, the number of samples required for one full period of each waveform is different, and daq mx doesn't seem to like me doing 'writes' of different lengths within the same task.. Is there some way to get it to do this.
If not, the only way I can see to get it to work is to determine the lowest common multiple between the three waveforms and then repeat each waveform however many times is required to make them periodic with each other. My issue with this is that if you have three frequencies that are very close together (eg 6.5 Hz, 7 Hz and 7.5 Hz) the number of repeats of each to make them periodic with each other would be enormous, requiring a massive buffer size, which seems inefficient.
What i'd ideally like is a way of getting each channel to loop around its own custom length buffer within the same daqmx task? Is this possible or do, or is there something similar which might work..... or do I need to go down the LCM and large bufffer route?
Thank you for your help,
Tom
11-20-2015 05:32 AM
This may be a silly question, but if you are correct that one DAQmx Task won't support multiple frequencies of D/A (I can believe that!), then why not set up three tasks, one per frequency, and start them together?
Bob Schor
11-20-2015 05:48 AM
Hi Bob,
Thanks for your help with this. I actually have the sample rates all the same, it's the frequency of the sine waves contained in the waveforms that varies between channels. Eg.. at 1kHz sampling rate, a 2 Hz wave has 500 samples for a single period and a 1 Hz wave has 1000 samples in it. My problem is in trying to get the 2Hz wave to loop around a 500 sample buffer and and the 1 Hz wave to loop around a 1000 sample buffer, for example.
Separate tasks would be good, but LabVIEW wont let me do that from the same output module (NI9263) saying that the resources are already being used.
Thanks again,
Tom
11-20-2015 05:58 AM
Hi Tom,
My problem is in trying to get the 2Hz wave to loop around a 500 sample buffer and and the 1 Hz wave to loop around a 1000 sample buffer, for example.
What's the problem with having two "waves" of your 2Hz sine at the same time of just one period of your 1Hz sine?
Use 1000 samples for both signals…
11-20-2015 06:01 AM
@Bob_Schor wrote:
This may be a silly question, but if you are correct that one DAQmx Task won't support multiple frequencies of D/A (I can believe that!), then why not set up three tasks, one per frequency, and start them together?
Not a silly question, but depending on the hardware there is a limit to the number of tasks you can create depending on the type of task (e.g. AO, AI, Digital) and the total number of tasks on the device. I don't think it's possible to create tasks of the same type with different sampling frequencies (although it might be possible on the top-end DAQ devices?) because you're essentially asking the device to multiplex the channels at different (and perhaps conflicting) intervals.
Ah...now that you've replied to Bob I understand better what you mean now. I don't know that much about how you fill the cyclic output buffer and what options you have to interact with it but if my understanding is correct - you should be able to write an array of waveforms containing a single period of data sampled at 1kHz (as that's your output frequency) and do a DAQmx write. I think you need to turn on automatic regeneration (so it loops around). It might complain that the number of samples is not the same length? Is that what you've already tried?
11-20-2015 06:11 AM
Hi GerdW,
Thanks for your reply. That would be fine for the example I gave, but if you have one at 3 Hz, another at 7 Hz and another at 1.25 Hz and a fourth at 0.77 Hz, then you'd have to find the LCM of these four periods and the smallest common repeat of them all might be an array hundreds of thousands of samples long.
If you could loop around independently, then you'd only have to provide one period of each signal.
Thanks,
Tom
11-20-2015 06:13 AM
Ah...now that you've replied to Bob I understand better what you mean now. I don't know that much about how you fill the cyclic output buffer and what options you have to interact with it but if my understanding is correct - you should be able to write an array of waveforms containing a single period of data sampled at 1kHz (as that's your output frequency) and do a DAQmx write. I think you need to turn on automatic regeneration (so it loops around). It might complain that the number of samples is not the same length? Is that what you've already tried?
Yes, that's what I tried. I.e. giving each channel an array of a different length, but it does indeed complain that the arrays are not the same length.
Thanks,
Tom
11-20-2015 06:48 AM
Do you have a simple VI that shows what you're doing? I tried to see if there was an example of using the buffer generation but I'm interested in having a look - I was wondering if there is a property node or something that allows you to change the buffer position?
Rather than try to send the entire waveform to the DAQ device, could you not generate and stream it in parts from the windows VI? So rather than send the full waveform, break it up into chunks to transfer to the hardware. I think if you turn generation off, it will append it to the end of your current buffer.
11-20-2015 10:47 AM
Hmm, NI-9263 says to have 4 simultaneous analog outputs. I thought it means it has 4 independent DACs.
Then what resource is common for them that does not allow to use them independently? What specification of the board should I check if I need 4 truly independent outputs?
11-20-2015 12:18 PM