Arduino Modbus RTU to AdvancedHMI(its works)

Hello,

I have been looking around for a good Modbus RTU library. I finally found

I noticed others were struggling to get AdvancedHMI to talk with Arduino.

I built a test Sketch and test AdvancedHMI project where I read and write coils. Read and Write to Registers.

Modbus is a little esoteric, so I would like to post the AdvancedHMI project and the Arduino sketch somewhere.

Stuff I struggled with
-Finding a library that included Coils, most were just Holding Registers
-Installing Modbus library, was getting not valid library. Had to unzip folder then rezip folders on level above library.
-You can write Signed Ints into Holding Registers
-Unsigned Ints are Modbus standard but AdvancedHMI had to use a "U"prefix infront of PLCAddress
-Figuring out that Holding Register of 0 in Arduino code mapped to 40001 in Advanced HMI
-New people to Modbus might not know that sometimes you have to guess at the Offset and you need to know that Coils are at 0xxxx, Holding Registers at 4xxxx

  1. I recommend go get the Modbus-Aruduino library by Andre
  2. Download latest AdvancedHMI
  3. Get qModbus, as debug tool(watch out all registers are 0 based, function code takes care of 0x or 4x)
  4. Run Andre's example, prove to yourself that you can read and write coils into Library example, using qModbus
  5. Follow AdvancedHMI instructions on how to build solution, setup comm port, etc
    Then borrow any ideas from my attached sketch

I will post my AdvancedHMI solution to google drive with link later

ModbusRTUAdvancedHMI.ino (2.45 KB)

you can find the AdvancedHMI solution here that works with sketch
https://drive.google.com/open?id=17GSh-2Xh0CZMOoHPDz-X6jVyF_RFeDv_