Appendix b. example program, N appendix b – Campbell Scientific CS526 ISFET pH Probe User Manual
Page 23

Appendix B. Example Program
The following is a CR1000 program that measures the CS526. This program
assumes the CS526 is connected to COM1 (C1 / TX and C2 / RX) on the
CR1000.
'CR1000 Series Datalogger
'Declare variable for digital pH measurement
Public pHCount
'Declare variables for serial input from sensor
Dim rawstring As String * 20, pHDigit(2)
'Main Program
BeginProg
'Set up datalogger port for serial communication
SerialOpen ( Com1,2400,16,0,41)
'Establish program scan rate of 60 seconds
Scan (60,Sec,0,0)
'Send get data command to CS526
SerialOut (Com1,"1M1!"&CHR(13),"",0,0)
'Set up COM1 to receive incoming serial data.
'Set timeout to maximum 200 mS
SerialIn (rawstring,Com1,20,0,20)
'Split out digital count value for pH from string input
SplitStr (pHDigit(),rawstring,"String",2,0)
pHCount = pHDigit(2)
NextScan
EndProg
B-1