11-22-2024 02:46 PM
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.
11-22-2024 05:15 PM
what is the problem with your code ?
Share it pls .
11-24-2024 03:10 PM
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:
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
11-24-2024 05:52 PM
@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.
11-25-2024 07:36 AM
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,
11-25-2024 08:01 AM
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
11-25-2024 10:20 AM - edited 11-25-2024 10:22 AM
@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.
11-25-2024 10:34 AM
Thanks Mr. Knight,
Finally used your second example link (Dead zone in a tank).
Than you all for your help and suggestions.
11-25-2024 10:56 AM - edited 11-25-2024 11:00 AM
@Meanjean2119 wrote:
Finally used your second example link (Dead zone in a tank).
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.
11-25-2024 11:54 AM
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.