LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert string to boolean help

Great afternoon Labview team,

 

  I was trying to get assistance in converting string to boolean to illuminate the corresponding LED, please refer to attachment. I had issues trying to figure out move pen VI, need more instruction. I just want to match the string to the correct LED to identify valve position. 

0 Kudos
Message 1 of 27
(1,476 Views)
most users will not have LabVIEW 2021 installed yet, so you use "save for previous..." to save for an older version of LabVIEW and get more eyes on your VI.

If you know what your text will be, for example "true" or "false", you can simply use an "equals?" comparator with a string "true" to get a boolean result. You can use "to lowercase" on the input string to ensure it is lowercase, and trim whitespace if there is any chance for extra spaces.
0 Kudos
Message 2 of 27
(1,458 Views)

I know the result string is going to be go1, go2, go3, go4, go5, go6, trying to figure out how to change string to Boolean? Is there a way to convert string to illuminate the corresponding LED?

0 Kudos
Message 3 of 27
(1,452 Views)

I cannot see your code to get a better idea, but I believe a simple case structure with your string as the case selector input should work. Based on the received string (go1, go2, etc), you can switch the respective led (as boolean constants). 

 

Cheers, 

Renato.

Regards,

Renato Giovanini
Product Engineer
AVIBRAS Aerospace
0 Kudos
Message 4 of 27
(1,436 Views)

I was able to come up with this, it functions to identify the correct valve. Only issue is the time the LED stays illuminated, its too short. Any recommendations?

Download All
0 Kudos
Message 5 of 27
(1,435 Views)

that code section inside the event strucure is attached to a 100ms timeout, that is, every 100ms the serial buffer will be read. In case there is no new data to read, nothing will be sent to the leds. Try to increase that time or even define other event. Moreover, do you really need an event structure for that? 

Regards,

Renato Giovanini
Product Engineer
AVIBRAS Aerospace
0 Kudos
Message 6 of 27
(1,425 Views)

GO.png
Something like this work?
(Haven't seen the code yet)

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 7 of 27
(1,423 Views)

I increased the time, but that only changed how long it took to read and write. Should I put that portion of the VI in a while loop?

0 Kudos
Message 8 of 27
(1,418 Views)

Use a case structure as Renaldo said, creating a case for each possible outcome. Every case defaults to "False" and the selected case goes to "True". Take all of the Boolean outputs and build them into an array and create an indicator for this array. Create a property node for this indicator so you can reset the LED's to all "False" at the beginning of the vi. The proper LED in the array will stay lit until the vi is run again.

0 Kudos
Message 9 of 27
(1,361 Views)

@JC54 wrote:

Use a case structure as Renaldo said, creating a case for each possible outcome. Every case defaults to "False" and the selected case goes to "True". Take all of the Boolean outputs and build them into an array and create an indicator for this array. Create a property node for this indicator so you can reset the LED's to all "False" at the beginning of the vi. The proper LED in the array will stay lit until the vi is run again.


So nothing like the code I posted at all???😉
the only thing wrong is the simulation of the go string and breaking it out into multiple processes.
It could be done as one function instead.

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 10 of 27
(1,350 Views)