NI Home > Community > NI Discussion Forums

LabVIEW

Reply
Member
Martin_T
Posts: 15
0 Kudos
Accepted Solution

Change value of Boolean toggle switch during runtime

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

 

 

Proven Zealot
GerdW
Posts: 9,198
0 Kudos

Re: Change value of Boolean toggle switch during runtime

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 :smileywink:

 

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


CLAD, using 2009SP1 + LV2011SP1 (sometimes even LV2013SP1) on WinXP+Win7+cRIO
Kudos are welcome :smileywink:
Member
Martin_T
Posts: 15
0 Kudos

Re: Change value of Boolean toggle switch during runtime

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

 

Member
Asad_Tirmizi
Posts: 97

Re: Change value of Boolean toggle switch during runtime

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
Member
Asad_Tirmizi
Posts: 97

Re: Change value of Boolean toggle switch during runtime

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
Proven Zealot
GerdW
Posts: 9,198
0 Kudos

Re: Change value of Boolean toggle switch during runtime

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 :smileywink:

Best regards,
GerdW


CLAD, using 2009SP1 + LV2011SP1 (sometimes even LV2013SP1) on WinXP+Win7+cRIO
Kudos are welcome :smileywink:
Member
Asad_Tirmizi
Posts: 97

Re: Change value of Boolean toggle switch during runtime

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
Proven Zealot
GerdW
Posts: 9,198

Re: Change value of Boolean toggle switch during runtime

Hi Martin & Asad,

 

well, the problem is even easier to solve :smileywink:

 

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


CLAD, using 2009SP1 + LV2011SP1 (sometimes even LV2013SP1) on WinXP+Win7+cRIO
Kudos are welcome :smileywink:
Member
Martin_T
Posts: 15
0 Kudos

Re: Change value of Boolean toggle switch during runtime

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

 

 

Proven Zealot
GerdW
Posts: 9,198

Re: Change value of Boolean toggle switch during runtime

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


CLAD, using 2009SP1 + LV2011SP1 (sometimes even LV2013SP1) on WinXP+Win7+cRIO
Kudos are welcome :smileywink: