Jump to content

Initiate command based off serial output


Kubo

Recommended Posts

QUOTE (Kubo @ Feb 12 2009, 05:19 PM)

I have a basic serial communication thats going to be running in the back ground of my test. I attached a picture of part that will be running it.

How can I have a command initiated when a certain line of characters appear in the serial connection output terminal?

Thanks guys!

Look under string functions and lookup the examples on serial port use!

Link to comment

First I would recommend a more robust architecture for your application. It would benefit from a state machine as well as parallel tasks using queues or notifies to pass messages. With that said you need to read the serial port and compare the messages read using the various string functions. You could use regular expressions or more basic comparisons. Without any details on the types and format of the messages your device sends it is difficult to make anything more than very basic suggestions.

Also, it is not necessary to reconfigure your Visa connection every loop iteration. This should really only be done once outside the loop. The loop should only be reading the serial port and taking the correct action when it sees the desired message.I also have to ask if you really want to read both ports within the same loop. Would your application be more robust and flexible if each port was handled individually or are they truly related to each other?

Link to comment

If you're new at LabVIEW, things can be a little overwhelming. It sounds like your application is working so I wouldn't change anything right now. Look at my attached image for a suggestion to do what you want. Some of the string primitives in LabVIEW require a bit of extra code to get them to do what you want. For example, in the image attached, I had to add a >=0 function to find out if my string actually matched.

PS. I added a linefeed character to your string building. That might make your Terminal output a little more readable.

Link to comment

QUOTE (Mark Yedinak @ Feb 12 2009, 06:33 PM)

First I would recommend a more robust architecture for your application. It would benefit from a state machine as well as parallel tasks using queues or notifies to pass messages. With that said you need to read the serial port and compare the messages read using the various string functions. You could use regular expressions or more basic comparisons. Without any details on the types and format of the messages your device sends it is difficult to make anything more than very basic suggestions.

Also, it is not necessary to reconfigure your Visa connection every loop iteration. This should really only be done once outside the loop. The loop should only be reading the serial port and taking the correct action when it sees the desired message.I also have to ask if you really want to read both ports within the same loop. Would your application be more robust and flexible if each port was handled individually or are they truly related to each other?

Yeah I figured this is a rough draft... I have only been using Labview for about 2 weeks now on the side. I am still figuring out all the small things. But as long at it works I can at least have a running test station up. Ill figure out all the small things later. But thank you for the input. The inputs are not related to each other, I will look into putting them as you stated.

QUOTE (Michael Aivaliotis @ Feb 12 2009, 07:24 PM)

If you're new at LabVIEW, things can be a little overwhelming. It sounds like your application is working so I wouldn't change anything right now. Look at my attached image for a suggestion to do what you want. Some of the string primitives in LabVIEW require a bit of extra code to get them to do what you want. For example, in the image attached, I had to add a >=0 function to find out if my string actually matched.

PS. I added a linefeed character to your string building. That might make your Terminal output a little more readable.

THANK YOU! Yes this works great! Just as it should! I appriciate it!

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.