11-02-2009 01:29 AM
Hi everyone,
Is it possible to change the value of a Boolean toggle switch during runtime?
I am making a programme, where the user can toggle a relay on/off. However, I want the programme to override the user input if a measured value exceeds a predefined threshold value.
The programme below almost does what I want. The major problem is that it if the measured value returns below the threshold value, the relay will be turned back on if the switch is set to "true".
I would be very grateful for any suggestions to solve this!
Best regards, Martin
Solved! Go to Solution.
11-02-2009 01:48 AM
Hi Martin,
you said: "override the user input if a measured value exceeds a predefined threshold" - this reads like "don't override when measured value is fine"... So your program does just that what you want to do
You should better define what should happen when the measured value is within it's definition range to decide what to program...
11-02-2009 02:00 AM
@ GerdW 11-02-2009 01:48 AM
I'm sorry if I didn't manage to describe what I want to do. I'll give it another try:
1. The user should be able to change the state of the relay when the threshold value is not exceeded.
2. If the threshold value is exceeded the relay should be turned off.
3. If the threshold value returns to a value below the threshold, the user should be able to change the value again. However, the state of the relay should not change back automatically.
The programme will be used to turn off pumps and to close valves. The user should be able to turn them back on and open the valves again if the measured value goes below the threshold value, but this should absolutely not happen automatically.
Best regards, Martin
11-02-2009 02:01 AM
You can change a boolean toggle switch during runtime. Well i made your programme and yes if the trigger will go beneath the threshold which in your case is 10, and the toggle switch is true than the indicator will turn on. wat do u want to do ? if the trigger goes above the threshold once u dun want the LED to turn on even if goes beneath the threshold later on?
If thats the case you can use the logic gates to invert the switch once the threshold is crossed. In such a case the relay wont turn on unless the toggle switch is manually turned on by the user.
11-02-2009 02:04 AM
11-02-2009 02:24 AM
11-02-2009 02:53 AM
The case strcutures seem to be the best solution for you. But as far as i can understand. You dont want the relay to work once the trigger has been activated. Even if the trigger reverts back to normal you dont want the relay LED to light up untill a user says so. That means with the trigger the toggle should automatically switch to off mode.
I couldnot make the toggle to switch off when the trigger is struck. So what ive done is that once the trigger crosses the threshold the VI stops. Making the threshold crossing impossible. and the relay will only operate when it is inside the envelope.
11-02-2009 03:36 AM
11-02-2009 03:37 AM
Many thanks to both Asad Tirmizi and GerdW. The Case Structure and local variable worked the way I wanted.
The programme now looks like this:
with the "true"-case like this:
Best regards, Martin
11-02-2009 03:40 AM
Hi Martin,
now the vi looks quite similar.
I prefer to put terminals outside of structures as most as possible - LabView has some optimizations for that case. And don't forget some delays in UI loops (a general recommendation)!