Data aquisition in Loop: sleep messing things up?
Zijon
Essentially I am trying to get data out of various entries in different waves (which are constantly updated) into another (2d) wave.
I have created global variables with the correct dependencies and these refresh perfectly. I created a manual-entry-button and that works just fine: i get values y1 and y2 into the next row of my wave.
now the problem:
if i create a loop to get the data, wait a second and then get the data again, for some reason i get identical entries in every row of my wave....
here is my approach right now (code for a checkbox)
if (checked == 1)
print "on"
nvar measurements=root:vacuum:measurements
nvar druck=root:vacuum:druck
nvar qvalue=root:vacuum:qvalue
wave vaquum
do
vaquum[measurements][%pressure]=Druck
vaquum[measurements][%qvalue]=qvalue
measurements=measurements+1
sleep/C=-1 /t 60
print measurements
print druck
if(measurements>1023)
break
endif
while (checked==1)
else
print "off"
endif
All I want this to do is to act as if I am pressing the button mentioned above every second.
Any Idea where I am going wrong??? Some hints would be greatly appreciated!
Thanks for your time,
Jonathan
print "on"
nvar measurements=root:vacuum:measurements
nvar druck=root:vacuum:druck
nvar qvalue=root:vacuum:qvalue
wave vaquum
do
vaquum[measurements][%pressure]=Druck
vaquum[measurements][%qvalue]=qvalue
measurements=measurements+1
sleep/C=-1 /t 60
print measurements
print druck
if(measurements>1023)
break
endif
while (checked==1)
else
print "off"
endif
April 4, 2013 at 05:01 am - Permalink
DoUpdate
after the Sleep command. I think you need to call DoUpdate when in a user function to update dependencies.April 4, 2013 at 06:14 am - Permalink
Thanks for your reply, sadly I had already tried that. The GUI pretty much freezes when I check the box "on". The only way to stop the loop at that point is abort...
April 4, 2013 at 07:50 am - Permalink
With a one-second period, I would program this as a background task. To learn more, execute this command on Igor's command line:
DisplayHelpTopic "Background Tasks"
Be sure to use a named background task.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
April 4, 2013 at 09:01 am - Permalink
the
DoXOPIdle
command did not do the trick but changing it to a background task sure did!!! Thank you so much for your rapid and extremely helpful reply. It works like a charm now. I had been suffering over this for days...April 5, 2013 at 06:29 am - Permalink