Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Read ModBus Sensor with CR1000


Monte Jan 26, 2010 09:19 PM

Hello

I've a sensor acting as a ModBus slave, supporting the ModBus function 3 (hex 03).

I'm using a CR1000 with OS 17.

CR1000 Com1 communication parameters are 9600 baud, 8 data bits, 1 stop bit, no parity.

The sensors ModBus adress is 1. (hex 01)
First register is 40002-40000=2. (hex 02)
Numbers of registers to read are 2. (hex 02)

The correct hex ModBus string for this is:
01 (Slave Device Adress)
03 (Function)
00 02 (start register)
00 02 (register size)
65 CB (CRC)

I think that the corresponding ModBusMaster instruction should look like this:
ModBusMaster (ResCode,Com1,9600,1,3,ModByte,2,2,3,100)
But using this command, the CR1000 send these bytes to the sensor: 01 03 00 01 00 04 15 C9
The start register is "00 01" instead of "00 02", and register size is "00 04" instaed of "00 02".

But when I use this command, where ModBusStart is "3" and ModBusLength is "1":
ModBusMaster (Result,Com1,9600,1,3,ModbusData(),3,1,3,100)
Then the output from CR1000 to the sensor is correct:
01 03 00 02 00 02 65 CB

Can anybody explain this?

* Last updated by: Monte on 1/26/2010 @ 2:28 PM *


Monte Jan 26, 2010 10:02 PM

I found the explanation for the register size prameter in the CRBasic help file:
"A floating point ModBus number requires two registers. The ModbusMaster instruction takes care of asking for the correct number of registers. Request the actual number of values you want to retrieve from the ModBus slave.
If reading or writing Floating Point values, the Length is the number of Floating Point variables, not the number of ModBus registers (which is two times the number of variables)."
So requesting 1 (fp value) equals to 2 (registers).

But the start paramater is still mysterious to me.


Karl Jan 26, 2010 10:56 PM

If you are starting with register 40000 then 40002 is the third register, 0, 1, and 2. It is probably this way because the sensor is using protocol addresses (base 0).

* Last updated by: Karl on 1/26/2010 @ 4:26 PM *

Log in or register to post/reply in the forum.