LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Combo box to code

Hello! I have a device connected with my PC with RS-232. I have a combo box with several choices. I want every choice I select be translated in code that my device can understand. How can I do that?
0 Kudos
Message 1 of 62
(4,228 Views)
Hi treadagon,
you can create a 2d array. Insert in one column all string which should be visible in the combobox and in the second row all your commands. If the user select a new value in the combo box, search for it in the first array and use the index to get your command from the second. If this no help please give more information.
 
Mike
0 Kudos
Message 2 of 62
(4,220 Views)
Thanks a lot for your fast response Mike! Well I'm a bit new to this one... Can you guide me please to act out your proposed solution? As I understand this array would have an input (from the combo box) and an output (the command) to VISA write. The arrays I saw in LabView they have only output. Thanks again!
0 Kudos
Message 3 of 62
(4,218 Views)

Hi treadagon,

try the attached example.
Hope it helps.

Mike

0 Kudos
Message 4 of 62
(4,215 Views)
Thank you! Yes that was helpful enough! I' m trying to understand now. (Because I'm about to explain it to my supervisor).
The 1st "Index Array" block is to specify the choice of the user from the combo box. Then you take this line as 1D Array.
The "Search 1D Array" block is to find in this line the user choice and then show to the 2nd "Index Array" block the code to choose.

Are those right?

And some questions I cannot understand:

Why have you used an event structure?
What is the role of the property node?
What is this "NewVal" thing in the case structure?

The while loop reads the every time the array or just once until the choice is changed? (I don't want to send the command to the VISA several times.)


Message Edited by treadagon on 06-05-2008 11:31 AM

Message Edited by treadagon on 06-05-2008 11:33 AM
0 Kudos
Message 5 of 62
(4,187 Views)
Hi treadagon,
yes that is right!

I used an event structure because i think a combo box is a user input and so i can react on user events.
The property node is to write the values from the first array into the combo box.
The "New Value" property gives you the current selected value, is the same as in the control.

Mike
0 Kudos
Message 6 of 62
(4,172 Views)
Thanks a lot again! But there is one more problem. The device cannot read any command if the place I write it is in "normal display". Even I put the "\" at commands the device won't read them till I specify them as '\' codes display. So, is there a way to specify the 1st column to be in normal display and the 2nd column be in '\' codes display?

And one more thing. Your solution will work properly in my block diagram if I remove the while loop? (Because I'm thinking to put a greater while loop in the whole block diagram)
0 Kudos
Message 7 of 62
(4,157 Views)

Hi treadagon,

it is not possible to change only one column, but you can use two separate arrays.
It should also work if you remove the while loop, the loop is only to test different values.

Mike

0 Kudos
Message 8 of 62
(4,155 Views)
Is my attempt correct? I put several choices in the combo box (the same as in array) but when I run the vi it always keep just the 1st one. I tried save the vi but nothing!!! When I run they just DISAPPEAR!!! Smiley Mad why?
0 Kudos
Message 9 of 62
(4,149 Views)
Hi treadagon,
if you use two separate arrays, then use 1d arrays or connect a 0 to the column index.
 
 
Mike


Message Edited by MikeS81 on 06-06-2008 01:06 PM
0 Kudos
Message 10 of 62
(4,146 Views)