11-18-2009 06:57 AM
Hello,
I´ve got a task where I have to output two waveforms on two analog outs (USB 6259OEM) while a six channel analog-in dataaquisition runs simultaneously. Now I have to change one of the waveforms (lets say on AO1) while the other waveform continues to run unchanged. This change should not influence the running six channel dataaquisition. So stopping the tasks and re-initializing with new waveform data will not work and updating the waveform data without stopping the tasks during runtime will cause a huge delay until the new waveform will be visible on the output...
Think it`s easy but I did not get the point how to manage this.
I`ve added the code with both options (stopping and re-initializing and updating during runtime) maybe somebody can can give me a hint how to solve this...
Thanks & best regards
Markus
11-18-2009 10:58 AM
Markus,
The following thread points to an example which might help:
http://forums.ni.com/ni/board/message?board.id=250&message.id=49032&requireLogin=False
Christian
11-19-2009 05:15 AM
Hello,
thanks for your reply but unfortunately it won`t help.
I`ve already checked the examples with waveform generation but they are all generating only without a parallel analog in.
I did the changes on the code as mentioned in the thread above (see attachment)
-not allow regeneration
-set timeout to 0 for write
-updating waveform data continously in a while loop... no effect at all :-((
Even with the "output buffer size" property set to the same amout of samples my waveform data contains, the delay will be there.
It lasts ~10 complete (old)waveform cycles until the new waveform becomes active, so I wonder where all these samples came from.
best regards
Markus
11-19-2009 08:13 AM
Hi Markus,
I guess its a problem due to the architecture of your code. The update of the AO values is still software timed.
If you run the VI mentioned in the link I posted before with a very small buffer size, like 10 or 20 samples, you will see that an update of the values in software take immediate effect on the output, it's because with every iteration new values will be written to the buffer.
If you say that you update the AO values in SW and it takes 10 buffer cycles until they will be written to the AO, then somewhere in your code the DAQmxWrite.vi will be called 10 times with the old values before the new ones will be written.
Christian
11-19-2009 09:07 AM
Hello,
that`s what I thought too, but the architecture is an "event driven queued state machine" and the "DAQmx write/DAQmx read" will be called only once per AO/AI cycle.
Nevertheless I think I`m a bit closer to the solution, the problem seems to be that I write a waveform of 4 seconds length and do the sampling for 2 seconds only and then writing the next waveform of 4 seconds length.
When I set the sampling length in my code to 4 seconds too the update of AO will appear within 1 waveform cycle.
So, now I need to split the data sampled from the complete waveform cycle in two halves and process them seperately 😞
However you`ve brought me to the right way...
Thanks
Markus