From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Change value of Boolean toggle switch during runtime

Solved!
Go to solution

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".

 

Picture 1.jpg 

 

 

I would be very grateful for any suggestions to solve this!

 

Best regards, Martin

 

 

0 Kudos
Message 1 of 14
(20,703 Views)

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 Smiley Wink

 

You should better define what should happen when the measured value is within it's definition range to decide what to program...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 14
(20,696 Views)

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

 

0 Kudos
Message 3 of 14
(20,692 Views)

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.

Regards
Asad Tirmizi
Design Engineer
Institute of Avionics and Aeronautics

" Its never too late to be, what u want to be"
Using LabVIEW 8.2
Message 4 of 14
(20,691 Views)
yeah right, thats what i pre empted u want to do.
Regards
Asad Tirmizi
Design Engineer
Institute of Avionics and Aeronautics

" Its never too late to be, what u want to be"
Using LabVIEW 8.2
Message 5 of 14
(20,688 Views)

Hi Martin,

 

ok, now you explained it better!

 

You need "IF trigger=TRUE THEN switch=FALSE", so use a case structure and a local of switch Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 14
(20,680 Views)

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.

Regards
Asad Tirmizi
Design Engineer
Institute of Avionics and Aeronautics

" Its never too late to be, what u want to be"
Using LabVIEW 8.2
Message 7 of 14
(20,657 Views)
Solution
Accepted by Martin_T

Hi Martin & Asad,

 

well, the problem is even easier to solve Smiley Wink

 

After cleaning up Asad's example, removing that RubeGoldberg, putting in some wait states and making a proper stop button I reattached the example... 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 14
(20,646 Views)

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:

Picture 1.jpg

with the "true"-case like this:

Picture 2.jpg

 

Best regards, Martin

 

 

0 Kudos
Message 9 of 14
(20,641 Views)

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)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 10 of 14
(20,639 Views)