This is an example program for a CS460 connected directly to a CR6 via RS485, using the Keller protocol. The same code should work on a CR1000X, with just changing the comport. Some older CS460 have firmware that didn't include support for Modbus. This example should work with all versions, and some other Keller transducer models.
'CR6 Series Datalogger 'date: Aug 31, 2018 'program author: Jacob Davis, CSI 'Example program to read level and pressure from a Keller Acculevel (CS460) ' The connection is RS485. The analog measurement is redundant, but was included for testing. ' This program is using sensor address 250, which only works with one CS460 on the channel. ' Note that checksums are not being verified in this program. 'Wiring 'Acculevel CR6 ' RED --------- U5 ' WHT --------- G ' BLK --------- 12v ' BLU --------- C2 ' YEL --------- C1 'Declare Public Variables Public PTemp, Batt_Volt Public Acculevel(3) Public se_level_voltage Alias Acculevel(1) = WaterPress Alias Acculevel(2) = WaterTemp Alias Acculevel(3) = KellerStatus Units WaterPress = bar Units WaterTemp = degC 'Define Data Tables. DataTable (Test,1,-1) 'Set table size to # of records, or -1 to autoallocate. DataInterval (0,10,Min,10) Minimum (1,Batt_Volt,FP2,False,False) Sample (1,PTemp,FP2) Sample (3,Acculevel(),IEEE4) EndTable Sub ReadKellerAcculevel(KellerPort As Long, KellerValue(3) As Float) 'Poll Keller Acculevel using Keller Protocol 'Return Values ' Water pressure in bars ' Water temperature in degrees C ' Status Code, expect a value of 0 for good measurements Dim K_OutString As String * 12 Dim K_InputString As String * 12 Dim K_BytesReturned As Long 'Using address 250 for all commands. Address 250 works with any sensor, but can only have one connected. 'Send poll command for water pressure K_OutString(1,1,1) = CHR(250) K_OutString(1,1,2) = CHR(73) K_OutString(1,1,3) = CHR(1) K_OutString(1,1,4) = CHR(161) K_OutString(1,1,5) = CHR(167) Erase(K_InputString) SerialFlush(KellerPort) SerialOutBlock (KellerPort,K_OutString,5) Delay(1,30,mSec) 'Delay to allow for response K_BytesReturned = SerialInChk(KellerPort) If K_BytesReturned < 9 Then 'Need to initialize the sensor after a power cycle K_OutString(1,1,1) = CHR(250) K_OutString(1,1,2) = CHR(48) K_OutString(1,1,3) = CHR(4) K_OutString(1,1,4) = CHR(67) SerialOutBlock (KellerPort,K_OutString,4) ' May want to mark the readings as bad, otherwise the last values remain ' WaterPress = NAN ' WaterTemp = NAN KellerValue(3) = NAN Else SerialInBlock (KellerPort,K_InputString,9) KellerValue(3) = ASCII(K_InputString(1,1,7)) MoveBytes (KellerValue(1),0,K_InputString,2,4) 'Poll water temperature K_OutString(1,1,1) = CHR(250) K_OutString(1,1,2) = CHR(73) K_OutString(1,1,3) = CHR(4) K_OutString(1,1,4) = CHR(162) K_OutString(1,1,5) = CHR(103) Delay(1,500,mSec) 'delay between commands Erase(K_InputString) SerialFlush(KellerPort) SerialOutBlock (KellerPort,K_OutString,5) Delay(1,30,mSec) 'Delay to allow for response SerialInBlock (KellerPort,K_InputString,9) MoveBytes (KellerValue(2),0,K_InputString,2,4) EndIf EndSub 'Main Program BeginProg 'default settings 8,N,1,9600 Address 1 SerialOpen (ComC1,9600,19,0,20,4) Scan (5,Sec,0,0) PanelTemp (PTemp,15000) Battery (Batt_Volt) VoltSe (se_level_voltage,1,mV5000,U5,True,0,60,1.0,0) 'Regular analog measurement of level Call ReadKellerAcculevel(ComC1, Acculevel()) 'Poll Keller Acculevel using Keller Protocol 'Call Output Tables CallTable Test NextScan EndProg