Hi All,
I am new to the world of Modbus with limited understanding of the protocol and use with CSI loggers. I have a new instrument for test deployment that has 4-20mA HART as primary output but can also produce RS485 Modbus. The sensor is an Anton Paar L-Dens Desnity sensor, manual https://dl.dropboxusercontent.com/u/59753806/C77IB001EN-B_L-Dens_4x7T_D___Ex__Interfaces_Instruction_Manual-1.pdf
I have been able to communicate with the sensor with an RS232 - 485 adaptor and check the results and setup and all looks ok. The trouble I am having is matching the CRBasic code with what the sensor registers. I think i am on the right path as I am getting an error messgae from the sensor rather than a connectiong fault (ModbusResult = -2) The manual implies this is an "Illegal Data Address - The data address is not permitted in the device"
The values I am looking for are in Input registers as Float variables, Address 30021 for Fluid temperature, 300029 for Density and 300031 for specific Gravity.
The base code I started from Scwin for the Modbus setup with CR800 datalogger.
The interface I am using is an Intech 2400-IS USB to serial Converter http://www.intech.co.nz/products/remotestations/2400-is.html) connected to the RS232 port on the logger with a null modem adaptor. Wiring of sensor is 485 A/+ to the tx+ and 485 B/- to tx-
'CR800 Series
'Created by Short Cut (3.2)
'Declare Variables and Units
Public BattV
Public PTemp_C
Public ModbusResult
Public Modbus(10)
Units BattV=Volts
Units PTemp_C=Deg C
'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,60,Min,10)
Sample(1,ModbusResult,FP2)
Sample(1,Modbus(1),FP2)
EndTable
DataTable(Table2,True,-1)
DataInterval(0,1440,Min,10)
Minimum(1,BattV,FP2,False,False)
EndTable
'Main Program
BeginProg
'Use SerialOpen to set RS232 options for Modbus Master Instruction
SerialOpen(COMRS232,9600,2,0,1000)
'Main Scan
Scan(5,Sec,1,0)
'Default CR800 Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
'Default CR800 Datalogger Wiring Panel Temperature measurement 'PTemp_C'
PanelTemp(PTemp_C,_50Hz)
'Modbus Master Instruction
ModbusMaster(ModbusResult,COMRS232,9600,1,3,Modbus(),1,8,3,100,3)
'Call Data Tables and Store Data
CallTable Table1
CallTable Table2
NextScan
EndProg
Any help much appreciated
Try
Public ModbusResult
Public Modbus(10)
BeginProg
SerialOpen(COMRS232,9600,2,0,1000) 'Sensor 4-pole DIP switch, all set to off
Scan(5,Sec,1,0)
ModbusMaster(ModbusResult,COMRS232,9600,1,4,Modbus(),21,8,3,100,0)
NextScan
EndProg
Thanks Skyler,
I tried the code as you recomended but I am still getting the -2 Modbus result.
I am trying to work with the suppliers to check that the request is correct and the sensor is setup correctly
also got the books out to find out more on the modbus
Feel free to call in for more direct support.
Update... success
Thanks to local industrial sparky to assist on the modbus decode and sort out what the sensor was doing with freebie modbus test prgram (ModbusMAT)
Turned out the sensor would fault on calling address 300035 so limiting the length was key. Also the length is the number of measurements not addresses as each measurement is two addresses
Additionally the sensor needed the full start address, despite loggernet adding it which was a head scratcher. finally the 32 bit float no reversal was required to get the output correct
cammand ModbusMaster(ModbusResult,COMRS232,9600,1,4,Modbus(),30019,6,3,1000,2)
Not sure if this is of any use to others but the test program was extremely helpful, makes me appreciate sdi-12 more