LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Monitoring the serial port

I am trying to design a program that will allow me to control an instrument and monitor any data being sent / recieved on the Com 1 port.
 
I have sorted out the control side of the program but the monitoring part of the program, I am having problems with. I would like to be able to view the data being sent / recieved like you can in Hyperterminal.
 
The instrument that I am controlling has some basic commands to start and stop it, however data is only sent from the instrument when a reading is stopped.
 
When I control the instrument from Hyperterminal, i can monitor the data and pull the information that I want. Is there a way that I can monitor the Com port data in Labview?
0 Kudos
Message 1 of 12
(3,326 Views)
Take a look at examples shipped with labview. Go to the Example Finder in Help->Find Examples and type in the keyword serial into the search tab. You will see a number of VI's listed for serial comms.
 
Have fun!
 
David
0 Kudos
Message 2 of 12
(3,316 Views)
I have looked at those examples before and have tried implementing them into my program with no success.
 
Any other ideas?
0 Kudos
Message 3 of 12
(3,308 Views)

Was there any errors?

What data did you send? Give me an example of what you are trying to send to the device

What data should you receive? Give me an example of what you expect to see back.

You could also post what you have done so using the Attachment button below the Message body when you post.

Basically we will need as much info to give us a clue what could be going wrong.

cheers

David

0 Kudos
Message 4 of 12
(3,304 Views)

David

Errors that occured were timeouts!

The data that I am sending to the instrument is 'h/00' , this command tells the instrument to start. 'i/00' stops the instrument from taking a reading and when it does this, it automatically does a screen dump of from the instrument on the RS232 data cable.

What I am trying to do is have my program ready to accept the data that is sent out from the instrument and record it.

The data that comes back is just ASCII, such as 'Time : 20 seconds'

I would like to attach sample code of what I am trying to do but there are no facilities where I work to upload anything onto the web.

I can get the same result of a screen dump if i push the stop button on the front of the instrument, I have just been trying to create a program that will capture the data when it see's it, The program normally comes back saying that the VISA read vi has timed out.

In the ideal situation I would like a Hyperterminal window displaying the data that is being sent / received on Com 1 and a labview program with buttons to control the instrument.

0 Kudos
Message 5 of 12
(3,292 Views)
If you use the VISA functions to read/write from/to the serial port, you can use the "Bytes at Port" property to see whether bytes are available to read at the serial port. See attached picture. This would read bytes from the serial port until a line feed is detected. Careful, this example would cycle forever if no line feed is received. You might want to use the error clusters or a timeout as additional stop conditions.

0 Kudos
Message 6 of 12
(3,275 Views)
you also can use NI-spy to watch what happens underneath
greetings from the Netherlands
0 Kudos
Message 7 of 12
(3,258 Views)

You can use the "bytes at port" without any termination character.
What I try to do is call the "bytes at port" followed by a comparison
(>0) followed by a case statement with the VISA Read in true. If there
is data in the receive buffer you can read it and process it, and if
there is no data in the receive buffer you don't do anything.

Good Luck
Eric

0 Kudos
Message 8 of 12
(3,253 Views)
I have tried what has been suggested and it does as you say, the data is being displayed in my string indicator when the instrument outputs the screen dump. I have now come across another problem where the data that is sent from the instrument does not stay in the string indicator for me to read.
 
It looks as if the data comes in has a line feed after each of the lines within the screen dump, so i see the screen dump one line at a time but this is updated after each line feed (this cycles through very fast so i can not read any of the measurements). This means that I am not able to display the screen dump in its entirety to the user.
 
Can anyone suggest anything
 
Thanks
 
Paul
0 Kudos
Message 9 of 12
(3,228 Views)

There is a property node that you can use to move the scroll position within the string indicator

This will ensure that scroll position  is always beyond the length of your string.

Let us know if that helps you

David

Message Edited by David Crawford on 09-14-2006 11:50 AM

0 Kudos
Message 10 of 12
(3,221 Views)