LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How read values from Waveform (DBL) 1d Array and compare it with a double value

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:

 

23670i4D09571CD2F967EC

 

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:

 

23672i66826CA6077470E9

 

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

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 11 of 13
(1,072 Views)

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?

0 Kudos
Message 12 of 13
(909 Views)

Hi camr,

 

please don't hijack old threads and stick with your own one!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 13 of 13
(891 Views)