I am new to the Forum and mostly new to Arduino.
I am currently using a MKR1000 and I have a MKR485 Shield on it.
My project goal is to test Modbus functionality by sending Information from an Allen-Bradley Micrologix 1100(1763-L16BWA)as a Modbus Master(Client) to the MKR through its 485 interface as a Modbus Slave(Server).
The Libraries I am using for this are ArduinoModbus and ArduinoRS485, and the Program(posted) is the sample Program(ModbusRTUServerLED) supplied w/ ArduinoModbus. The Program configures a single Coil at address 0 and reads the value of that coil, then sets the Built-in LED depending on the returned Value. I have made two changes to the Stock program(though I have tried this without Changes) and those are:
-Added a few lines to print Coil 0-3 and NL.(just in case I'm off by one address)
-Changed the BAUD Rate to 19200.(My application speed)
On the PLC side, I have a MSG instruction set up on Channel 0(Serial Port,Mini-DIN 8.) with the Channel configured as:
-Driver:Modbus RTU Master
-Handshaking:No Handshaking(485 Network)
I have the MSG configured as:
Modbus Command:15(Write Multiple Coils)
Data Table Address:B3:0/5
Size in Elements:4
MB Data Address:1(0)
This MSG is sent every 4 seconds.
With this Configuration I cannot get the Arduino to receive anything. This is not the only thing I have tried. I have tried other PLCs,an Ethernet/IP>>Modbus Protocol Gateway, and another Arduino. The only way I have been able to get anything at all to work is when I connected an Arduino Mega 2560 using a tinysineRS485 shield set to UART/RS485 with its RS485 Interface. And this way I could get the MKR to receive Modbus RTU data as well as RS485 ASCII. The other way around, however, MKR sending, Mega Receiving did not work, the Mega got data but couldn't read it on any Baud Rate(was something like ?h?????N??). I am starting to think that the issue there may be that I'm not supposed to have the devices connected to the Computer when using Modbus Comms? I don't know enough about Arduinos to tell. Anyway, I verified that the three pins I am using from the PLC are correct with another Modbus Device and an Oscilloscope reads data coming through when expected, but my Scope isn't fancy enough to read differential signal so I can't tell if it's the right data or not.
Modbus_Test14.ino (1.6 KB)