LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to select control buttons linked to fixed strings?

A Newbie here - How do I setup a row of button controls each of which, when selected, cause a fixed string to be output into a serial port write? (This then sends out a presert command to a serial device)
Tia, Dave
0 Kudos
Message 1 of 7
(3,619 Views)
The easiest way is to take the data from each of the buttons and put them into an array builder. Take the output of this array builder and pass it to a 1D array search function that is searching for the first array element that set to a TRUE (meaning the button has been pressed). The output of this search routine will be either a -1 (meaning no buttons were pressed) or the index of the button that was pressed.

If the output is -1, do nothing. Otherwise, use the index to index into an array of command strings and send the selected string to the serial port.

If you need more detail let me know and I'll put something together for you...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 7
(3,619 Views)
This is the perfect situation to use the event structure(LabVIEW 6.1). Put an event structure in a while loop and configure an event for each button that sends the corresponding string to the serial port.

Ray K
Applications Engineer
National Instruments
0 Kudos
Message 3 of 7
(3,619 Views)
Thanks, Ray ..
Is there an example like this in the tutorial somewhere that I missed? It's still not clear how to do this. I tried adding several CASE statements, but I don't know how to make each one (and only that one) trigger when its button is pushed. It can't be that hard, so I'm missing something.. Thanks!
0 Kudos
Message 4 of 7
(3,619 Views)
Mike ..
I don't know how to "take the data from each button" yet.. I tried the array builder, but don't know how to control it - nor do I know how to "Index into an array of command strings". Sorry for being so unknowledgable! Do you have an example I could see? Thanks!!
0 Kudos
Message 5 of 7
(3,619 Views)
Here is an example program I just coded up. The event structure is only available in LabVIEW 6.1 so this program will only work in 6.1. I put dummy data in the serial write commands so you need to replace the data with the appropriate commands.
Ray Kong
0 Kudos
Message 6 of 7
(3,619 Views)
Here is the sample code that I promised. Unlike the other solution you were sent, this will work with any version of LV, not just LV6.1 Pro.

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 7
(3,619 Views)