pockey Posted January 17, 2007 Report Share Posted January 17, 2007 Hi, everyone I am writing a LabVIEW program to test a board through COM Port, User should send commands to the board and the corresponding response should be displayed on the String indicator on the Front panel. By now, I only know the way of using buttons to send commands, I use a "Build Array" and "Search 1D Array" to assign each button a number and do the corresponding operation in the case structure... However, to be more user-friendly, I need to replace some of the buttons with ComboBox and Toggle Switch, since these controls are different from buttons, I did not know how to implement them... I tried to use a Toggle switch, for each "on" or "off" state, different commands should be sent to the board. I hope command sent to the board once when user click the switch. By default, I hope nothing would happen. It seems I should use a "event structure", however, I failed to do so ...My problem is how to make the Combox or Toggle Switch act as buttons and combined these cases with buttons without conflict. By now, all the "value1/value2/value3/on/off" are represented by a button... Could anyone give me some suggestion to replace the "2403.33 MHz/2442.24 MHz/2479.10 MHz" to a Combobox and "XCEN 0/XCEN 1" to a Toggle switch?? I think I need to know more about the properties of controls... Admin Note: Please read the following for information on how to post images on LAVA: How to Insert Images in your Posts, Making a good first impression Download File:post-6631-1169006264.vi Quote Link to comment
Ton Plomp Posted January 17, 2007 Report Share Posted January 17, 2007 Hi, everyoneI tried to use a Toggle switch, for each "on" or "off" state, different commands should be sent to the board. I hope command sent to the board once when user click the switch. By default, I hope nothing would happen. It seems I should use a "event structure", however, I failed to do so ...My problem is how to make the Combox or Toggle Switch act as buttons and combined these cases with buttons without conflict. When I said yesterday messed up portal I meant that the portal was so wide it wouldn't fit my (widescreen) window on my laptop, please host your pictures at lava Then you definitely need the Event structure, where you said a string to write and do a read in the timeout case: Now a trick would be set the label of the boolean to the string you want to write, and the caption to the text you want the user to see (in this case you don't even need that since you use the boolean texts), put the booleans into 2 or three clusters (the Islands you have created on your FP look nice). The following code could be yours: Download File:post-2399-1169010633.vi Ton Quote Link to comment
pockey Posted January 17, 2007 Author Report Share Posted January 17, 2007 Thanks, Tcplomp! Is it the same with "Combobox"? I could set the label according to different index? Quote Link to comment
Ton Plomp Posted January 17, 2007 Report Share Posted January 17, 2007 Thanks, Tcplomp!Is it the same with "Combobox"? I could set the label according to different index? What is combobox? First try to implement my structure with the event case Ton Quote Link to comment
robijn Posted January 17, 2007 Report Share Posted January 17, 2007 Hi, You'll have a hard time debugging apps like this. And making any extension to it will especially be difficult. You can check each time if the valueof a combobox has changed, but it's much easier to detect it with an event structure and a value change. I see you did use the shift register to store the comm transcript. If you go for some state machine / queued message handler (for example the one I proposed to you earlier) you should put that string in the state cluster. Joris Quote Link to comment
Ashish Uttarwar Posted January 17, 2007 Report Share Posted January 17, 2007 However, to be more user-friendly, I need to replace some of the buttons with ComboBox and Toggle Switch, since these controls are different from buttons, I did not know how to implement them... Pockey, I made a VI based on what I understood from your message. I hope that helps. Basically, you can use event structure for any kind of controls...buttons...combo box..etc. Check out the VI. Regards, Ashish Download File:post-2466-1169073863.vi Quote Link to comment
pockey Posted January 18, 2007 Author Report Share Posted January 18, 2007 Thanks a lot, ashishuttarwar! Your example shows me the usage of Toggle Switch However, for "Combo box", the command sent is the same as the value, I hope to send "r 0x24ad" for "2403.33 MHz", how could I assign different commands to different values of a "Combo box". In C#, it's quite easy to use a event handler and with { if(combobox.text=="2403.33 MHz") comport.write("r 0x24ad");}... It's difficult to get the same result with LabVIEW, at least for me at this stage. Is there any Compare or Match function in LabVIEW to compare the current select of a Combo box? Quote Link to comment
ned Posted January 18, 2007 Report Share Posted January 18, 2007 However, for "Combo box", the command sent is the same as the value, I hope to send "r 0x24ad" for "2403.33 MHz", how could I assign different commands to different values of a "Combo box".In C#, it's quite easy to use a event handler and with { if(combobox.text=="2403.33 MHz") comport.write("r 0x24ad");}... It's difficult to get the same result with LabVIEW, at least for me at this stage. Is there any Compare or Match function in LabVIEW to compare the current select of a Combo box? These things are not difficult in LabVIEW; you just need to think about them differently. In your case, I don't think you want to use a combo box. Instead, you could use a ring or an enumeration, which looks the same to the user, but has a numeric data type. Then, create a constant array of strings with the values you want to write to the COM port. Use the numeric value from the front panel control as an index into the array of strings to determine which string to send. Quote Link to comment
pockey Posted January 19, 2007 Author Report Share Posted January 19, 2007 Thanks, ned! Since I'm just using LabVIEW, I still did not know "Ring/Enumeration" before... I'll try your suggestion and try to think differently (I'm used to think with C# and Visual Studio...) Quote Link to comment
Ashish Uttarwar Posted January 19, 2007 Report Share Posted January 19, 2007 Since I'm just using LabVIEW, I still did not know "Ring/Enumeration" before... Hi, I have modified my previous example and used ENUM instead of Combo. You can moify ENUM values by right click menu options. Also, you can pass different values than ENUM using Case Structure. I hope that helps. Regards, Ashish Download File:post-2466-1169170639.vi Quote Link to comment
pockey Posted January 19, 2007 Author Report Share Posted January 19, 2007 Thanks a lot, ashishuttarwar ! I've got the result by ned's method, and you show me another approach. I'll try to think with LabVIEW! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.