Modbus

Hi,
I made some projects in tha past, but I am very inexperienced in protocoll work except Serial.Print command feeding back data via USB.

Here is my question. I'd like to connect a sensor (and the interface to the sensor is not problem) to feed into a engine control unit. The engine control unit has the following data shown on their webpage:

Modbus 57600 baud
8N1 format
no hardware handshaking

Total 47 Bytes per packet

  • Byte 0 = slave address = 0x01
  • Byte 1 = command = 0x03 (read holding registers)
  • Byte 2 = word count = 21 (there are 21 word values for the gauges to log)
  • Bytes 3 to 44 = actual data
  • Bytes 45 and 46 = CRC (can be used for data integrity, or can be ignored).

Can someone give me a hint how to implement this into Arduino? :~

It would appear that each time the device sends data, it sends 47 bytes. So, wait for there to be 47 bytes or more to read, then read 47 bytes.

My Arduino would not be the "reader" but the "writer" (so I am the master?)

Then, every time you need to write to it, you need to send 47 bytes. You will need to know what values you want to put in each of those 47 bytes. The receiving device will almost certainly not ignore the last two bytes, so, you need to understand how it computes the CRC value, so you can compute it the same way, so the values match.