LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is a Shift Register the Best Solution? Comparing Values when they Reach a Specific Threshold (peak or vally of singal)?

Solved!
Go to solution

Hello!

I am attempting to count how many times a signal turns beyond a specific threshold. For example, an initial peak or valley occurs in the signal with a value of 10. I want to compare this value of 10 to the next peak/valley data points until I find one that is greater or less than 5/-5 from that value of 10  (i.e. at least 15/-15). So 14 would not count and the program would continue to look for the next peak/valley. If a peak/valley value was 22, it would then save this as a "turn" on a counter and report the total difference between the initial and new value (ie if the initial value was 10 and the new value was 22, it would be a difference of 12 and add "1" to an overall counter). This process would then continue from the value 22 and keep comparing peak/valleys to that new number of 22 until a new peak/valley is greater or less than 5/-5 of the value of 20 (ie at least 17/27). The values may be negative or positive in the overall comparisons.

 

I have been able to identify the peak/valleys, but when I attempt to compare them using shift registers I cant figure out how to perform it this way. I can compare each data point to the next etc, but to perform a function as described I have been unsuccessful. I am unsure if a shift register is the best way to accomplish this and I am open to new ideas/suggestions. I hope someone has experience performing something similar to this and would be willing to guide me in the right direction.

 

Thank you for your time!

0 Kudos
Message 1 of 6
(2,355 Views)
Solution
Accepted by topic author CSmith8

Use a feedback node and a Select instead of shift registers. Wire the boolean to the Select of whether or not you hit a peak/valley that was valid for your logic. On the true case of the Select, wire in the new peak/valley value and on the false case wire in the output of the Feedback node. The result of the Select should go into the Feedback node.

Message 2 of 6
(2,346 Views)

@CSmith8 wrote:

 

I have been able to identify the peak/valleys, but when I attempt to compare them using shift registers I cant figure out how to perform it this way.

This is usually the time it would help to show us some code so we can get the context, see what's wrong, and suggest a solution.

Message 3 of 6
(2,344 Views)

@heath89 wrote:

Use a feedback node and a Select instead of shift registers. Wire the boolean to the Select of whether or not you hit a peak/valley that was valid for your logic. On the true case of the Select, wire in the new peak/valley value and on the false case wire in the output of the Feedback node. The result of the Select should go into the Feedback node.


I would say, "Use whatever method is comfortable to you.  If you are comfortable with shift registers, use that.  If you're comfortable using feedback nodes, then use that, instead."

 

The only real advantage I can see with a feedback node (in this case) is that you don't have wires running across your FOR loop.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 4 of 6
(2,302 Views)

@billko wrote:

@heath89 wrote:

Use a feedback node and a Select instead of shift registers. Wire the boolean to the Select of whether or not you hit a peak/valley that was valid for your logic. On the true case of the Select, wire in the new peak/valley value and on the false case wire in the output of the Feedback node. The result of the Select should go into the Feedback node.


I would say, "Use whatever method is comfortable to you.  If you are comfortable with shift registers, use that.  If you're comfortable using feedback nodes, then use that, instead."

 

The only real advantage I can see with a feedback node (in this case) is that you don't have wires running across your FOR loop.


Good point, I guess the Select was the part that I should have emphasized. Make sure you don't update your shift register every iteration. Only change it when the new value is a peak/valley. Like was said earlier, It would help if we could see the code

Message 5 of 6
(2,299 Views)

Thank you all for your input. I took your example and it was quite helpful. Spent some time yesterday and today playing with feedback loops, as these were new for me. I was able to implement this into my program and it has worked great so far. Thank you for everyone who helped!

0 Kudos
Message 6 of 6
(2,277 Views)