Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial read from pH meter giving me varied output

Hi,
I'm trying to read data on the serial port from an Orion 720A pH meter. It's connected fine (I can talk to it with hyperterminal and get data back).

I've followed the Basic Serial Read example as well as a couple of others, but the output I get seems weird. I'm sure I'm just missing something.

What I need to do is to send it 2 commands (REM and PR) to get it into remote mode and request a printout. The vi is correctly sending these commands (meter flashes "Printing").

Then, typically, the readout simply shows me those commands back, but not the printout. I used an example that waited for a set number of bits, but the number I got was variable. I had the best luck with a loop that just kept reading from the port again and again... occasionally I would see the data I was looking for.

One thing that really puzzles me: I have a property node "Bytes at Port" to see how many bytes are waiting. I then pass this value to the VISA Read vi... this value is typically around 128, but the VISA Read reports that it read ~6 bytes (REM PR).

I'd greatly appreciate any help.   
thanks,
mike

0 Kudos
Message 1 of 5
(4,669 Views)
There's a couple of things you should do. First, if you want to flush the buffer, you should just do it after you configure the port and before the write. You don't want to be deleting anything that is a response to your command. Second, if the instrument returns mult-line strings, you don't want to enable the termination character. If the instrument returns a LF, then the VISA Read will stop as soon as it is seen. It doesn't matter how many characters are in the buffer or how many you tell it to read. The termination character is set and enabled with the VISA Configure Serial Port (turn on context help). To do things more efficiently, the VISA Configure Serial Port/Flush Buffer and the VISA Close should be outside your while loop. You only need to them one time. Lastly, are you sure the 'rem' and 'pr' can be combined in a single command. You might try sending the commands one at a time and terminate each with the CR constant.
Message 2 of 5
(4,658 Views)
Dennis,
Thanks so much. The termination character fixed it, and there is no way I ever would have found that without help. Thanks also for the style suggestions. My skill level is it-sort-a-works-but-probably-isn't-the-best-way-to-do-it, so any suggestions to clean things up are appreciated.

On the buffer flushing, I have a question. Those flushes were in there to try to stop echos... even now that it is working, the vi is reading back the "rem pr" that I send to the device (it does work to send them both as a single line, and avoids having the meter read back "ORION Meter type 720A Logged on:  (Enter help to view the menu)"... maybe I should send "rem" then flush the buffer, then send "pr"? ). I can't figure out why it reads back the command I sent it... it doesn't happen from a terminal... is there some way to turn of the echo?

Now to a whole bunch of string parsing to get my data out...

Thanks again,
mike

0 Kudos
Message 3 of 5
(4,649 Views)
Sorry, I can't think of a reason that you wopuld be getting an echo. I would try what you are thinking and send the commands one at a time.
0 Kudos
Message 4 of 5
(4,632 Views)

HI guys -

 

Hope you see this message!

 

I am also working on serial comms with an Orion pH meter and your VI was super useful! 

 

Thanks!

- Phil

0 Kudos
Message 5 of 5
(3,546 Views)