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.
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.
12-18-2013 03:19 PM
Hello,
I want to count how many times the Boolean state has changed. But somehow the stop button cannot abort the statement.
Solved! Go to Solution.
12-18-2013 03:24 PM
Study up on dataflow.
You're always going to be waiting in your inner while loops with this structure.
Look into Event Structures or using a Shift Register to track value changes.
Your polling while loops inside of another while loop will not work for your intended purpose.
12-18-2013 03:39 PM - edited 12-18-2013 03:40 PM
12-18-2013 03:43 PM
thx~
12-18-2013 03:53 PM - edited 12-18-2013 03:54 PM
@altenbach wrote:
Your code is way too constipated. Here's one simple solution.
Wiping coffee off my monitor now....
Sometimes you just know when someone's Freudian Slip is showing.
12-18-2013 04:01 PM - edited 12-18-2013 04:04 PM
No slip. thats exactly what I meant.
(the stop will work after switching the boolean a few times, it's just a constipation issue. Impaired dataflow) 😄
12-18-2013 04:38 PM
in the new attached file where i added "read digital input",
how to use one single stop button to abort the whole program with two loops,
and how to set the default port as "port 1" but not "port 0"?
12-18-2013 04:49 PM - edited 12-18-2013 04:52 PM
All you need is a single loop (and stop button). Just place the code from the lower loop inside the upper loop.
Your current code is not stable because the lower loop might miss an update (race conditions!). What determines the loop rate of the upper loop? Is there some hardware timing or does the loop need a small wait?
You could even monitor multiple lines by tapping into the boolean array and maintaining an array of numeric in the shift register. The rest of the code basically stays the same.