LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple Serial Com port

I have an external device that I need to write and read simple ascii commands to through a serial port. For some unknown reason I can not get Labview or for that matter M&A to com to it. I can com to it through a terminal (putty) with no problems. I have tried through M&A and also several labview basic read & Write Serial example VIs. No luck. All I need to send is  $1RD  This tells the external device to send a measurement back. Its basic ascii. The device coms on 19200 baud 8 bit words no party or flow control and 1 stop bit. Anyone have any ideas?

0 Kudos
Message 1 of 10
(1,792 Views)

You can get it to work with putty?

 

Do you have to hit the enter key in putty after you type in $1RD to get a reply?

 

If so are you sending the enter key (CR) in LabVIEW?

0 Kudos
Message 2 of 10
(1,789 Views)
It works fine in putty. Yes I have to press the enter key to send the $1RD. I have tried adding \r and \s to the end of the command in labview, but no luck.
0 Kudos
Message 3 of 10
(1,786 Views)

@Bkasper wrote:
It works fine in putty. Yes I have to press the enter key to send the $1RD. I have tried adding \r and \s to the end of the command in labview, but no luck.

Try adding a \r\n or just a \n to the end of the line. A carriage return by itself is not a normal line termination.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 10
(1,776 Views)

The "enter" key sends a New Line \n

 

In LabVIEW in the string constant that you are sending, type $1RD and just hit the enter key and not try to enter \r or \n.

0 Kudos
Message 5 of 10
(1,775 Views)
It had to be $1RD \n\r I tried the \r\n earliry but did not think of trying the n before the r. That made the difference. I also had to play with a ms pause between sending the $1RD\n\r and reading the return measurement. 50 ms worked well. Thanks for the help guys.
0 Kudos
Message 6 of 10
(1,767 Views)

There is an easier way to read/write ASCII on the serial port. We have developed a package on the LabVIEW Tools Network to automate serial port interactions. You can use it to replicate what you manually do using Putty in LabVIEW for serial devices such as responding to login prompts, entering commands, waiting for a response and returning it. You can find out more about it and download a 30-day free trial at: http://sine.ni.com/nips/cds/view/p/lang/en/nid/214248

Certified LabVIEW Architect (CLA)
0 Kudos
Message 7 of 10
(1,617 Views)

Bumping every thread you can find to sell your product is pretty much the definition of spam.

 

How about you calm down JUST a tad and limit yourself to posts that have had activity in the past couple years, at least?

0 Kudos
Message 8 of 10
(1,612 Views)

@ALAB wrote:

There is an easier way to read/write ASCII on the serial port. We have developed a package on the LabVIEW Tools Network to automate serial port interactions. You can use it to replicate what you manually do using Putty in LabVIEW for serial devices such as responding to login prompts, entering commands, waiting for a response and returning it. You can find out more about it and download a 30-day free trial at: http://sine.ni.com/nips/cds/view/p/lang/en/nid/214248


Your enthusiasm for your product had temporarily blinded you to basic forum etiquette.  Glad you regained your sight.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 10
(1,571 Views)

You shouldn't have to use a wait to get all the bytes that you need. I am assuming you are using serial communications.

 

If I do not know what the termination charaecter is, or just need to verify what the documentation is telling me, I like to first just do a basic write/read communication with some high millisecond wait. I usually set it up to something like 500ms, then read what the string output is on the VISA Read function and turn on CODES DISPLAY and look at the last charaecter that was recieved. When I know that, I just set the termination charaecter to the right code, enable the termination character to true, take out the wait, set the bytes to read to something higher than you would ever expect, and it works much faster and is usually more efficient.

 

Just my two cents...

 

 

0 Kudos
Message 10 of 10
(1,552 Views)