06-10-2010 08:07 AM
Hello,
I'd like to drive independantly 4 valves, each one with different timing constraint.
This, through a usb cdaq9174 and a 9265 module (4-20mA generator).
For instance :
Write a data on the channel1 of the 9265 at time T0, then
Write a data on the channel3 of the 9265 at time T1, then
Write a data on the channel2 of the 9265 at time T2, then
Write a data on the channel2 of the 9265 at time T3, then
and so on...
I mean, I haven't constant dt for each channel (then no waveform possible, isn't ?).
And I can't select the channel when I write.
Thanks for your answer.
Christophe
06-10-2010 08:29 AM
What are some typical values for T0, T1, T2, T3? What kind of precision do you need on that timing?
Assuming that the timing needs are no more accurate than the order of milliseconds, the you should just use DAQmx write of 1 channel 1 sample any time you need to change the analog output. Have a fast running while loop, determine one each iteration whether the time has met the T0 through T3 threshold for each of those channels, and if it has, just write out a new analog value for that particular channel. The other channels will continue to output whatever value was last written to them.
If the timing needs to be more precise, then try to come up with a time base that meets the requirements of all the T#'s, and build a waveform of N channels and N samples where you make the changes at the prescribed times.
06-11-2010 02:35 AM - edited 06-11-2010 02:40 AM
This is an example : each channel is actually independant...
The time between two write is never faster than 7ms for the sinus and 100ms for the others.
06-11-2010 09:43 AM
Sine wave (actually sort of a half sine wave?) = 7 ms between samples, square wave = 100 ms.
That leads to two choices.
1. Run a while loop with a 1 msec wait and write each sample at the appropriate transitions (every 7th iteration for the sine wave, every 100th iteration for the square wave.) The only risk is any jitter in the timing due to inconsistencies of the loop execution rate in windows.
2. Set up a waveform for each channel go with a 1 kHz rate and for a quantity of samples so that the waveform can repeat. Probably some multiple of 700.
06-11-2010 10:58 AM
Thanks. I think it could be a solution to write on each channel at the highest frequency, looking at the frequency of each channel.
Nevertheless, my question is : is it possible to write ONLY the necessary values, in order to set the valves position ?
Two valves have to be open or close. (4mA or 20mA) So only one write per command, at the good moment.
Two valves have to go to close state to close state, via the open state, and in a sinus way. (4mA...20mA...4mA)
Let's imagine that each write has a cost...
We've to changes the timing, for each valve, in real time, up to obtain the good flow condition in the experiment.
06-11-2010 11:18 AM
sinus sine wave (A sinus wave is a heartbeat rhythm which doesn not really look at all like a sine wave.)
You can write the same value over and over again at the higher frequency. There really is no "cost" for writes. All the writes for all the samples for all the channels are done at the same time, and only done once, if you are set up for continuous regeneration.