LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to get a case structure to execute only once in a loop

I have a while loop that is monitoring temperature. Once the temperature meets or exceeds a given setpoint I want to start a timer. At this point I don't want to monitor the temperature anymore. That is, if the temperature should drop below the setpoint, I don't want to execute the case structure again when the temperture meets or exceeds the setpoint(the temp may oscillate about the setpoint for a given period of time). In any event, I need the case structure to execute only one time, not every iteration of the loop.
0 Kudos
Message 1 of 4
(4,373 Views)
A case structure inside a while loop will always execute on every loop, just like any other objects inside the loop. The trick is to have a case structure with a boolean for an input, which is set true when the setpoint is reached. Inside the FALSE case, you put your code to monitor the temperature, and inside the TRUE case put nothing. When your setpoint is reached, the boolean is true and the TRUE case with nothing in it gets executed.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 4
(4,373 Views)
You can put a local Boolean variable "Flag" inside that case structure and
set "Flag" to False. Outside the case structure, use an "AND" function
output to control the case structure. The "AND" function has two inputs. One
goes to the comparison results between real temp and setpoint. The other
inputs connects to the "Flag" variable. In this way, once you entered that
case structure, the "Flag" will be turned to False, and then in next
iteration, you won't get into the case again because the "AND" function will
be False as your "Flag" is False now.

Hope this helps.

Rentian


1. Inside the case structure, put a
"BB Herman" wrote in message
news:50650000000800000094020100-1079395200000@exchange.ni.com...
>I have a while loop that is monitori
ng temperature. Once the
> temperature meets or exceeds a given setpoint I want to start a timer.
> At this point I don't want to monitor the temperature anymore. That
> is, if the temperature should drop below the setpoint, I don't want to
> execute the case structure again when the temperture meets or exceeds
> the setpoint(the temp may oscillate about the setpoint for a given
> period of time). In any event, I need the case structure to execute
> only one time, not every iteration of the loop.
0 Kudos
Message 3 of 4
(4,373 Views)
Thanks for your replys. The info was most useful.
0 Kudos
Message 4 of 4
(4,373 Views)