Jump to content

Checking serial port continously and acting on user input


bwgames

Recommended Posts

Is it possible, in LabView (8.0), to run two things at once?

I.e. I have a front panel with buttons and indicators.

Every 5 seconds or so, the device connected via serial port outputs a list of boolean states which should be used to update the boolean state of the FP indicators.

At the same time, if a button is pressed on the FP, a command needs to be sent via the serial port.

I can do the sending of the command by wiring the T/F output to a case structure and sending it that way (even though it gets horribly complex with ~40 buttons, each one wired to its own case statement - there must be a easier way?), but I'm not sure how to read the serial port at the same time. A timer to read the serial port every 5 seconds probably wouldn't work due to the fact it would need precise timing.

I want to be able to read the serial port and use the info to affect indicators whilst at the same time acting on any changes by the user to the FP.

Does anyone have any pointers/example VIs?

Thanks.

Link to comment

Hi bwgames,

welcome to lava!!!

"I want to be able to read the serial port and use the info to affect indicators whilst at the same time acting on any changes by the user to the FP."

e.g. you can run a sub VI dynamically for reading the serial port, while the main vi is acting on FP changes.

"(even though it gets horribly complex with ~40 buttons, each one wired to its own case statement - there must be a easier way?)"

You can put all buttons in one case. See the attachment.

hope it's helpful for you

Ulrich

Download File:post-3940-1156855192.vi

Link to comment

Thanks for the feedback. The case VI gave me exactly the info I needed.

Looking more closely at the Producer/Consumer(Data) template now - this seems to be exactly what I need - use a SubVi in the False case structure to process any button changes, and in the consumer loop, act on the array received from the serial port.

One question I do have - how would I set current boolean states of LEDs based on what is in an array cell? I.e. how would I link an array cell to a boolean indicator?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.