From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting only once when a case structure is true in a while loop

Solved!
Go to solution

Hi. First time posting here so do pardon me. I have tried searching for answers in the forums along with attempting the solution myself but to no avail.

 

Here is the problem. I am trying to collect voltage signals via the DAQ assistant. When a certain threshold voltage is reached, the "true" case would run. I am currently using the shift register along with the while loop hence the output number "numerical 2" would increase as the while loop runs. However, I only want to register a single case as long the voltage is above is above the threshold.

 

Eg. When the voltage is above 3V for some time, it registers only a 1. Then the voltage might dip below 3V. The next time the voltage is above 3V again it would register a 2. So on and so forth. I have attached an image of my block diagram below. Thanks for the help!

 

 

Capture.JPG

0 Kudos
Message 1 of 3
(2,713 Views)
Solution
Accepted by topic author repel89

Keep the status of the threshold reached in a shift register.  Perform an AND with the inverse of the value in the shift register and your new threshold detection.  The result of the AND goes into your case structure.

 

EDIT:  I just threw together this example.  I used a Feedback Node since it would be cleaner.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 3
(2,702 Views)

Hey. Thanks for the quick reply and assistance. The solution worked out for me. Cheers! 🙂

0 Kudos
Message 3 of 3
(2,668 Views)