LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple boolean control similar to hysterisis. Turns on at SPhigh then turn off at SPlow, but stays on on the way down.

Hello all, my first time posting.

 

Probably a simple fix, but can't seem to figure it out.

I have a voltage input(AI) that needs to turn on an output(Bool) when above a certain SPhigh. Voltage will then drop and needs to turn off output when below SPlow.

Initially output is off when going to SPhigh, then turns on and stays on on the way down until it reaches SPlow, then turns off.

 

Thanks for the help.

0 Kudos
Message 1 of 11
(517 Views)

what is the problem with your code ? 

Share it pls .

0 Kudos
Message 2 of 11
(474 Views)

You have a Voltage Input (I'll call it Vin) and a Boolean Output (Bool).  You also have two Voltages, Vhi and Vlo.

 

You want a VI that has the following properties:

  1. If Vin > Vhi, Bool = True.
  2. If Vin < Vlo, Bool = False.
  3. Otherwise, Bool is unchanged.

Take pencil and paper and try to draw out this (very simple) VI, with input Vin and output Bool.

 

Hint #1 -- You need a "memory" to handle Case 3, what to do if Vin is between Vlo and Vhi.

Hint #2 -- Have you learned about Shift Registers?

 

Bob Schor

0 Kudos
Message 3 of 11
(441 Views)

@Meanjean2119 wrote:

Initially output is off when going to SPhigh, then turns on and stays on on the way down until it reaches SPlow, then turns off.

 

Thanks for the help.


I guess this is a cooling system. In a heating system, the boolean would be reversed. Whatever the controller does when switch on (LED ON), it should tend to change the reading towards the range between low and high if outside that. Right?

 

This is a simple deadband control, and there are plenty of example in the forum (e.g. here or here). I am sure you can modify for your specific requirements.

 

0 Kudos
Message 4 of 11
(432 Views)

Hi Bob,

 

Thanks for your answer. Thing is, I need my output to be OFF from 0 to Vhi when going up, but ON from greater than Vhi to Vlow on the way down. And then OFF when lower than Vlow.

 

Thanks,

0 Kudos
Message 5 of 11
(408 Views)

Combine my response (where I say "Bool = False", you say "Output is OFF") with @Altenbach suggestion that you are describing a cooling system (so Output = On means temperature is getting lower) and (I hope) you'll see I am exactly describing the system you mentioned in your initial Post.  The only "uncertainty" is the "initial condition", where you start with a temperature between the High and Low levels but don't have an initial setting for the Boolean control (it can initially be either True or False).

 

Bob Schor

0 Kudos
Message 6 of 11
(401 Views)

@Meanjean2119 wrote:

Thanks for your answer. Thing is, I need my output to be OFF from 0 to Vhi when going up, but ON from greater than Vhi to Vlo on the way down. And then OFF when lower than Vlow.

 

Thanks,


In addition, you need to define all edge cases.

 

  • Should it be on or off when the first reading is between|above|below the two points?
  • Are there additional safety limits if the on/off control does not do what it is supposed to do? For example if "V" would continue to raise forever, going way above Vhi? Same for the other direction.
  • You mention zero. Can the process variable also go negative?
  • What are the initial values?
  • What are controls and what are constants? For example is the user allowed to change Vhi and Vlo during the run?
  • What should happen if the user sets Vhi < Vlo or Vhi=Vlo? Maybe a setpoint and gap width would be more intuitive as controls. 
  • What should happen if the VI is stopped? (e.g. set the boolean to a defined state).
  • etc etc.
0 Kudos
Message 7 of 11
(391 Views)

Thanks Mr. Knight,

 

Finally used your second example link (Dead zone in a tank).

Meanjean2119_0-1732552416919.png

 

Than you all for your help and suggestions.

0 Kudos
Message 8 of 11
(387 Views)

@Meanjean2119 wrote:

Finally used your second example link (Dead zone in a tank).

Meanjean2119_0-1732552416919.png

 


That code does not do anything reasonable, because it is just a one-shot downhill run and you seem to use a convoluted in-range check. If you think you have working code, attach the VI and explain exactly how it should be used. This way we can give more specific feedback.

 

  • What does the data in the 2D array signify and why is it 2D if you only care about the second row?
  • There are easier ways to get the last element directly.
  • Where does the array data come from?
  • What controls the state of the boolean control?
  • So. Many. Questions.
0 Kudos
Message 9 of 11
(379 Views)

This is meant to be a sub-vi. 

2D data is temperature, speed and acceleration. Since I'm only looking at speed data, I only need the second row.

The boolean control is used in a while loop with a shift register in the parent vi to make the sub-vi function. It loops back through "Go Speed In". "Go Speed Out" is used to execute data saving when speed is exceeding "target speed start acquisition". If actual speed goes under "target speed stop acquisition", then "Go Speed out" if false.

It work great in my application.

If you think there is a better way to do it, I'd be happy to look at it.

 

Thanks again.

0 Kudos
Message 10 of 11
(367 Views)