05-07-2019 02:12 AM
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
Solved! Go to Solution.
05-07-2019 02:58 AM
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.
05-07-2019 03:19 AM
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
05-07-2019 03:32 AM
If you save for previous version your existing code, I'll take a look.
05-07-2019 03:44 AM
OK, I save it to 2015 version. Thank you!
05-07-2019 04:51 AM
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?
05-07-2019 05:51 AM - edited 05-07-2019 05:57 AM
I saw your modification, it works the comparaison. But How Can I do to store te value detected and its location on time?
05-07-2019 06:13 AM - edited 05-07-2019 06:18 AM
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.
05-07-2019 06:47 AM
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.
05-07-2019 07:27 AM
Thank you, I understand. I will try to do the same thing for value and counter.