Hi,
So I've got a CS460 (Keller AccuLevel) pressure transducer hooked up to a CR1000's RS232 port via a RS232 to RS485 converter and a gender bender. I know that somehow, I have to use the Modbus Master function in CRBasic in order to communicate with it, but I have never used Modbus before. The communication protocol for the sensor can be found at http://www.keller-druck.com/picts/pdf/engl/comm_protocol_e.pdf
Have you checked out the help and example for the ModBusMaster instruction?
Yes I have, but it hasn't helped too much. In particular, I am still confused as to what inputs I need for function, variable, start, and length in order to get the pressure and temperature values from the sensor.
Looking at the manual you already provided the link to it seems like you could try
Function = 3
Start = &h0101
Length = 2
Format = 2
I've tried this
ModBusMaster (Result,COMRS232,-9600,1,3,Temp,&h0101,2,3,100,2)
but the Result comes back as 1, meaning that there was a communication failure. I know it's not a problem with the sensor or the converter or the power source, since I can read the sensor from my computer using Keller's Read30 program.
Comparing the operation of the logger to that of the computer is not a good one. Keller's software is more than likely using "Keller Bus" and not "Modbus".
If you are getting a result of "1" then you have a problem with your communications.
If you are getting a result of "-1" then you are communicating with the sensor but you have one or more of the parameters in the ModBusMaster instruction incorrect.
If the result is "1" (then 2, 3, 4, etc.), one or more of the following might be occurring:
a) You have the transmit and receive lines backwards when connecting the sensor the RS-232 port of the logger (you've specified the use of COMRS232 in your instruction).
b) You have the wrong baud rate selected
c) You have the Com port configured incorrectly (data bits, stop bits, parity, etc.)
d) You have specified the wrong COM port in your instruction, for example you've specified COMRS232 but it is attached to COM1.
e) You have specified the wrong Modbus Address, for example using an address of 1 when the sensor address is really 10
f) The timeout is too short, for example specifying a timeout of 1 second (100), but the sensor takes 5 seconds (500) to respond.
To Try:
Public Res1
Public Dat1(2)
Public Res2
Public Dat2(2)
BeginProg
Scan (10,Sec,0,0)
ModBusMaster (Res1,COMRS232,9600,1,3,Dat1,&h0100,2,3,100,2)
ModBusMaster (Res2,COMRS232,9600,1,3,Dat2,&h0101,2,3,100,2)
NextScan
EndProg
* Last updated by: Sam on 5/25/2013 @ 12:17 AM *
You were right, it was your suggestion a) which fixed it. I needed a null modem as part of my setup. Also, it seems I only have to run ModBusMaster once to get both values. Here is code that works.
Public Res1
Public Dat1(2)
Alias Dat1(1)=Pressure1 'bar
Alias Dat1(2)=Temp1 '°C
BeginProg
Scan(10,Sec,0,0)
ModBusMaster (Res1,COMRS232,9600,1,3,Dat1,&h0101,2,3,100,2)
NextScan
EndProg
I have a sample program for an instrument that uses a negative number for the start address parameter of the ModbusMaster command, in my case it uses -3 for holding register 0x0002 and -9 for holding register 0x0008. I can't find any reference in the CR1000 manual or the current crbasic help file for negative start addresses, except the following line from example 73 in the current (02/2018) CR1000 manual (pg 469):
ModbusMaster(Result,COMRS232,-115200,5,3,Register(),-1,2,3,100)
The sensor, a Keller series 31x level sensor doesn't report any values if I use a start address of 3 for register 0x0002. Why is the negative address required?
(It does work perfectly with Andrew's short program directly above, btw)