LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I generate a single timer event in a loop?

I have a simple PID script running inside of a timed loop to control a heating process.  It works perfectly except that I cannot find a clean way to start the timer when it reaches the setpoint.

 

Right now, the loop just runs for a set amount of time (e.g., thirty minutes).  I want it to run for a set amount of time after the heating reaches the setpoint.  I can think of several ways to fudge this, for example with a couple of shift registers and a case structure or with a second loop, but these options seem very clunky.

 

I am sure there is a better way.  Can I somehow create an event within the loop that only happens once, for example, to give a timer value one time when a boolean value changes and never rewrite it?

 

Thanks in advance for your help.

0 Kudos
Message 1 of 5
(2,424 Views)

You could keep the boolean value in a shift register or a feedback node.  You then need a little bit of logic to check to see if the boolean changed from false to true.  From there, you can put in your get timer inside of a case structure.


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
0 Kudos
Message 2 of 5
(2,384 Views)
I decided to just initialize a shift register at 0 and increment it every time the process value equals the setpoint. Then if it is greater than zero, it stops resetting the timer. Still a lot of unnecessary processing, but seems less messy and prone to errors than checking for a Boolean change each iteration.
0 Kudos
Message 3 of 5
(2,367 Views)

@stephencox wrote:
I decided to just initialize a shift register at 0 and increment it every time the process value equals the setpoint.

I probably would not use an equal comparison. What is the datatype of the value?

0 Kudos
Message 4 of 5
(2,357 Views)

Ok, it's not actually an equals comparison.  It increments the dummy value everytime the setpoint is within an acceptable range of the setpoint.  Anyway, datatype is integers, so equals would work--I'm using a cheapo USB thermocouple reader that outputs integer temperatures, which is fine because we can easily tolerate +/- 2 degrees during the run.  The important thing for us is to avoid overshoot, so we require a modified PID routine that heats very conservatively.

0 Kudos
Message 5 of 5
(2,354 Views)