09-12-2010 07:51 AM - edited 09-12-2010 07:52 AM
If what you want to do is stop as soon as you have recieved data that is equal to your 'Stop voltage' then ideally you will want to add it in the acquisition for loop:
I have replaced your DAQmx vi with a data control here as i dont have the vi on my computer so could not use it in a snippet. Will work the same though if implemented on your sample code. The 2 nested for loops basically search for your stop voltage from the given data and will exit immediately if found. The output of the outer for loop will be "TRUE" which will then exit the Acquisition for loop, also outputting a 'TRUE' value which will then stop your vi.
As has been mentioned, you cannot (Should not) use an equals comparison with doubles. In this example i have used and 'Approx Equal.vi' that i use. You can set the accuracy, set above to 3 decimal places. You can also select whether it rounds up/down/nearest (Default is nearest). Will attach this vi below. There are plenty of other ways (and no doubt better) to do this but has worked fine for me.
If you do not wish to exit the acquisition loop immediately but instead after all samples have been read (Like in your example) then you can place the added code outside your acquisition loop. You will need to add an extra for loop outside of the 2 nested loops though as you will be outputting an array of the acquired data:
There is most probably a more elegant way of doing the latter, rather the 3 nested for loops but it will do the job.
Regards,
Lucither
10-12-2014 10:41 AM
hi!
i am quite new and I think this thread will also healp me. instead of stop voltage, I have a series of voltages where my boolean will have a signal (blink).
how can this be applied?
10-12-2014 12:50 PM