LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare analog signal with threshold in real time

Solved!
Go to solution

Hello,

I try to compare signal that I acquire in real-time with NI USB 6008 to the threshold. I would that the programm detect all points that are high than the threshold (independing on the sample frequency) and stock in array the value of this points and their time of detection. After, I would add counter to count the times where the signal was high than the threshold.

I tried to use threshlod.vi but it doesn't work correctly. This is my programm for acquisition signal and for peak detector. But for comparator and counter i don't know how to do.

Can you help me please? thank you

0 Kudos
Message 1 of 22
(3,517 Views)

If you backsave to 2017, maybe 🙂

As a guess without being able to see your code (yet?), you can also just use the Greater Than comparison (rather than Threshold) to get an array of booleans, and then using conditional indexing or similar (perhaps, depending on your code structure) to get the values over the limit. The size of that array is the number of times over the limit, if looking for separate instances (i.e. only number of times crossing the threshold) you can look for changing edges in the boolean array or similar.


GCentral
0 Kudos
Message 2 of 22
(3,499 Views)

I have already tried to use Greater than comparaison, but it doesn't work correctly. Can you show me in code what do you use please? thank you

0 Kudos
Message 3 of 22
(3,494 Views)

If you save for previous version your existing code, I'll take a look.


GCentral
0 Kudos
Message 4 of 22
(3,489 Views)

OK, I save it to 2015 version. Thank you!

0 Kudos
Message 5 of 22
(3,486 Views)

Ok, so I ran your code with a simulated input signal and slightly rearranged the VI (uploaded below, sorry, I had to make it differential in my case because my simulated DAQ device doesn't support RSE).

 

The Threshold VI correctly identified values over the threshold and the # Found appeared to be at least approximately correct (I didn't count to check).

 

Is the problem that you want to store the values for more than one iteration?


GCentral
0 Kudos
Message 6 of 22
(3,470 Views)

I saw your modification, it works the comparaison. But How Can I do to store te value detected and its location on time?

0 Kudos
Message 7 of 22
(3,464 Views)

If you use a Shift Register or Feedback Node to store the array of locations from the previous iterations and append the new array generated by the Threshold VI (which might be an empty array) then that should do what you want.

 

You might need to add the value of the iteration time offset (i.e. the value being added to the Time array) to get ms compared to the start (rather than relative to the block, which with the default values I uploaded would be between 0 and 499 ms).

 

Edit: I attached an example for the locations. You could do the same for the values, and something very similar for the count.


GCentral
0 Kudos
Message 8 of 22
(3,458 Views)

For your modification about locations, is it the location for the values detected by the Greater comparator or the peak detector? because I would the locations for the values detected by Greater comparator not the peak detector.

0 Kudos
Message 9 of 22
(3,452 Views)

Thank you, I understand. I will try to do the same thing for value and counter.

0 Kudos
Message 10 of 22
(3,440 Views)