Discussion:
Synchronizinging READ WRITE tasks in the same WHILE loop (benefit + shortcoming)
(too old to reply)
tsunami
2008-08-01 01:10:08 UTC
Permalink
Attached is a VI that successfully synchronizes a READ & WRITE tasks within the same WHILE loop (it was not an easy chore).  The benefit is that the 2 tasks are sourced to the same AO clock source & occur at the same rate and avoids the burden of QUEUING which if implemented improperly would bogg down operation of the VI.  However, there is a flaw which I am seeking a solution.  The READ tasks is repeatedly stopped & restarted for each loop iteration.  The ramifications of this is that the counter in the READ task will miss encoder counts from a servo motor.  While this can be minimized it is not desireable.  Without stopping the READ task the error 200279 occurs do to the fact the WRITE task has not concluded its execution prior to the READ buffer filling up.  Simply adjusting buffer size between the 2 tasks does not seem viable because the errors can shift from 1 task to the other.  There may very well not be a solution to this dilemna since tying both tasks to the same clock source maybe overconstraining the problem.  Nonetheless, I know there are some very clever developers out there with experience that dwarfs mine so I thought I'd take a shot.  I also included the VI that does not STOP & RESTART the READ tasks in case anyone is curious to experiment.  To run the VI you need to set all your front panel settings first & have the OK button depressed.  Good setting values are illustrated in the attached PDF.
 
 
 
Error -200279 occurred at DAQmx Read (Counter 1D DBL 1Chan NSamp).vi:1
 
Possible reason(s):
Measurements: Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.
Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.
Property: RelativeToCorresponding Value: Current Read Position
Property: OffsetCorresponding Value:
Task Name: _unnamedTask<83>


front panel settings.pdf:
http://forums.ni.com/attachments/ni/250/42022/1/front panel settings.pdf


continuous READ.vi:
http://forums.ni.com/attachments/ni/250/42022/2/continuous READ.vi


stop restart READ.vi:
http://forums.ni.com/attachments/ni/250/42022/3/stop restart READ.vi
tsunami
2008-08-01 17:40:21 UTC
Permalink
I found a solution in DAQmx READ Property Nodes.  There is an option to allow buffer overwrite.  This could present problems itself but the alternative of stopping & starting the task is less desireable.
Loading...