07-27-2011 02:26 PM
Hello everyone,
I am communicating with a serial device using the VISA functions. My VISA commands are inside a loop, and per loop itteration I am sending a default command and receiving a message back from my device. However, I would like to incoroporate two non-default cases, which are to be initiated by buttons on the front pannel. When pressed, a corresponding command should be sent to the serial device only once, and then I'd like to go back to the default case. The message coming back fromt the device should be a string, common to all cases - I don't want a separate string per case. How can this be done efficiently?
I tried to do a three-case case structure, but I haven't figured out how to use boolean switch buttons for more than two cases (I prefer buttons to a drop-down menu selection). I also tried an event structure (which I have no experience using), but these remain idle, and I can't figure out how to make a default case run actively.
Thank you in advance for your help.
Solved! Go to Solution.
07-27-2011 02:56 PM - edited 07-27-2011 03:04 PM
Sounds like a good time to learn about the event structure.
This might help:
Community Event Structures Tutorial
Make sure you wire something other than -1 to the timeout and put your default code in the Timeout case.
Add cases for each of your buttons for your non-default actions.
Post your attempt and we'll adjust it if it doesn't do what you think it should.
07-27-2011 02:58 PM - edited 07-27-2011 02:59 PM
An event structure has a time out event which you could wire a value to. The default value (nothing wired to it) is -1 which means never timeout. You can put in a 0 which means zero timeout, execute the timeout case immediately if some other event hasn't already been queued. Or put in any value meaning milliseconds. Wait that many milliseconds and execute the timeout case if another event hasn't happened in the mean time.
Do combine multiple boolean buttons, build them into an array. Then search 1-D array for the first true. A -1 means none are true, a number from 0 to n-1 means that particular element of the array is true. So you just feed the value to the case structure. (-1,default 0 1 2 ...)
07-27-2011 03:28 PM
Do you have code that we can see that we can help with?
07-28-2011 08:45 AM
Thank you. It now makes more sense, and, more importantly, it WORKS!