mrgsdsjg Posted March 14, 2008 Report Share Posted March 14, 2008 Hi everyone, I am fairly new to LabVIEW and have been having a problem programing some code to write and read over the same serial port. Here goes: I need to be able to both write and read over the same serial port, but the trick is that I need to be able to write a message whenever one of several buttons is pressed, and read at all other times. The examples I have loaded up and played with all have selectors for either reading or writing, and if both are turned on, it will wait for me to write something, then read(whatever is in the read buffer), then wait for me to write something, then read again. Any help or examples would be greatly appreciated. I am loading a modified version of the Advanced serial write and read VI. Thanks for your help! Quote Link to comment
Justin Goeres Posted March 14, 2008 Report Share Posted March 14, 2008 QUOTE (mrgsdsjg @ Mar 13 2008, 11:12 AM) Any help or examples would be greatly appreciated. I am loading a modified version of the Advanced serial write and read VI. Thanks for your help! You're on the right track. And good job consulting the examples. That's half the battle . But rather than modifying the Advanced Serial Write and Read example to behave like an event-driven UI, a better approach would be to take something like the User Interface Event Handler template (File >> New... >> User Interface Event Handler) and add the serial read & write code that you need from the serial example. A really simple way to do it is to put your write operations in cases of an Event Structure (just like you've already done, although I'd probably use a Value Change event rather than a Mouse Up event, and set the booleans to Latch When Released). Then put your read operation in the Timeout case of the Event structure and wire something reasonable, like 100 ms to the timeout terminal of the Event Structure (see the LabVIEW Help for more info). This way, your program will execute the serial read every time the Event Structure times out (which is almost every time). But whenever you press one of the buttons, the event for that button will fire, triggering the associated serial write. Welcome to LabVIEW, and welcome to LAVA! 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.