NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
adamrussell
Posts: 30
0 Kudos

reading from serial port

In my labview life I have always used the gpib and never serial port. Now I
will have some devices that report their numbers over rs232. Is there
anything special I should know before I start in programming?
Active Participant
JellyBeans
Posts: 238
0 Kudos

Re: reading from serial port

1) Make sure you configure the serial port using the "Serial Port Init.vi" and then do the reads and writes.

2)Use the "Bytes at serial port.vi" to figure our how many bytes are there in the buffer and try not wiring the number to "Serial Read.vi" because if less bytes are there, you program will sit there and wait for the rest of bytes to come.

Remember you can also use VISA for serial comm.

A Rafiq
Active Participant
Lab Viewer
Posts: 499
0 Kudos

Re: reading from serial port

In addition to the previous post I want to say that a serial_read_withtimeout VI will be a big help.
Member
Helmut Hullen
Posts: 3
0 Kudos

Re: reading from serial port

Hallo, Adam,

Du (adamr) meintest am 20.08.01 zum Thema reading from serial port:

> Now I will have some devices that report their numbers over
> rs232. Is there anything special I should know before I start in
> programming?

Look into the examples - maybe there is one which you can import for
your purposes.

Greetings!
Helmut

Please excuse my gerlish!
Member
RRSA
Posts: 2
0 Kudos

Read bytes from serial port RS232?

Hi
 
I need to read bytes from serial port RS232 and than try to identify each one of the bits that I'm interested in. I have already tried the examples from "Advanced Serial Write and Read.vi" but i could't obtain any result.
Please give me some advices or examples how to implement a solution for reading from a serial port rs232.
Thank you
Knight of NI
Dennis_Knutson
Posts: 33,566

Re: Read bytes from serial port RS232?

That's a pretty good example. When you say you don't any results, is the return string blank or does it have characters you don't understand? Did you select the correct com port and do the settings match your instrument (i.e. baud rate, parity, etc.)? Have you tried using Hyperterminal? That's the first thing I always do. If it works there, then you know your have the settings correct and are using the right type of serial cable. Are you using a null modem or straight through cable?
Member
RRSA
Posts: 2
0 Kudos

Re: Read bytes from serial port RS232?

The result from the communication are characters that i don´t understand. I've selected the correct port and i think all settings match my instrument. Thank you for your advised, i´ll try Hyperterminal.
 
Member
Tom Haggerty
Posts: 104
0 Kudos

Re: Read bytes from serial port RS232?

For me, reading from the serial port, I usually have to convert the data in into the desired format.  The instrument I am reading from in the example is a torque controller that is manually operated.  I monitor the port continuously and when data comes in I read it.  It comes in as astring and I convert it based on the manufacturer'sspec as to what each ASCII character coming in represents.  I had to get a hex to ASCII conversion table from the internet -- just search for it -- to understand some of the numbers coming in. (If the torque read high, an extra character was sent, a hex 48, which in ASCII is a capital H)  so I had to handle that message differently.  The big thing is to understand what the instrument is putting out and hyperterminal is a way of doing that.   I am trying to include pictures.... we'll see if it works!
 
 
Member
Tom Haggerty
Posts: 104
0 Kudos

Re: Read bytes from serial port RS232?

 
Member
Tom Haggerty
Posts: 104
0 Kudos

Re: Read bytes from serial port RS232?

[ Edited ]

Message Edited by Tom Haggerty on 03-15-2007 07:21 AM