Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading pH and temperature from serial port

Solution is probably very simple, but by searching the forums and using the LabView help I haven't solved my problem yet. I have a pH meter connected to serial port and I need to read the pH value and temperature. The string that the connected meter puts out is usually "18.03.11 12:47 pH 6.238 26.1 øC 
Tauto". Everything works fine when I use Scan From String function and put the right initial scan location, but sometimes the string does change a little and the pH and temperature values are not in the exact same location and it gives "Scan failed. The input string does not contain data in the expected format" error. So I would like to know if I can use another function to aquire the data or what format string to use so it would pick up the the value right after letters pH or right before øC.

0 Kudos
Message 1 of 4
(3,632 Views)

Take a look at the string in /-code display and see if there is a termination character.  This can be set in the serial init (or via properties)

In the received string search for "pH.*C"  and if found use the scan string function.

Your scan string might be like "%.:pH/s%f/s%f/s" 

 

I ignored the date because it's in the future 😉

 

EDIT: ARRGH how do I disable the smily???   so with a extra space " % . : p H ....     the "%.:" will fix situations where the decimal seperator is set to , via OP. 😛 😛 😄

 

 

 

Message Edited by Henrik Volkers on 03-17-2010 02:08 PM
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 2 of 4
(3,626 Views)

Hi

 

I have a similar problem, my read strings look like this:

 

pH    6.493 pH 21.0 deg C  760 mmHg  3234 AGC 1694 RAGC 02/29/2008 03:55:22

 

How can i scan just the pH (ie the 6.493) from my read string?

 

Is there a resource for string formatting that I can look at?

 

Thanks for your help,

Tatiana

0 Kudos
Message 3 of 4
(3,548 Views)

The LabVIEW Help on Scan From String contains a link for the various format strings that you can use. For your example you could do something like this:

 

Message 4 of 4
(3,539 Views)