Hello,
I have a problem. I’m working on a university project. My task is to create a device for reading RFID cards for employees at a company site. I am building the RFID card reader using an Arduino UNO with an RC522 RFID module and an Ethernet shield. As the master, I am using a B&R 5PP520 PLC. My problem is that both the slave and master connect to a computer via the Modbus TCP/IP protocol, but they do not maintain a connection with each other. I have attached a screenshot showing the status and hardware module error. If anyone has encountered a similar problem, I would greatly appreciate any suggestions for a solution.
Best regards.
Hi,
it’s hard to say without having more data, but for me it seems that there’s something wrong inside the configuration of the slave blocks about accessing the slaves data:
- ModSlavesState = 2 means, that the slave is connected
- ModbusErrorLast = 2 means “invalid data address”, so for example trying to access data out of the data/address area the slave provides
- LastErrBlockNr = 1 means, that the error occured at data block 1
The complete documentation about the diagnostic data points for a slave can be found here.
I think you first have to check the slave channel and IO mapping configuration you’ve done in the Automation Studio project regarding the data block / start address, the range of data to read/write and the modbus command using for access.
Best regards!
Hi,
thank you for your response and for your time. To add some additional information, the slave device is an Arduino with a simple program from its internal library. Attached, I am sending additional screenshots from the simulation of the master/slave setup using the Modbus Poll program. As you can see, both devices are communicating correctly with the computer. I also tried using the library included in Automation Studio called AsMbTCP; the results are similar, and I am also attaching a screenshot.
Best regards.
Hi,
Since the PLC master communicates with the PC based slave (MBslave), and the Arduino slave communicates with the PC based master (MBPoll), the general setup and function on both sides should be ok.
But because the PLC and Arduino do not communicate to each other, there must be some configuration issue, for example about the response timeout, the unit identifier, or something else.
- Could you please post a screenshot of the module configuration? (ModbusTcp_any Configuration)
- Do you have the possibility to make a network trace with Wireshark of the communications working and not working?
- if I interprete the Arduino IDE outputs right, it seems that the PLC master opens a TCP connection (“client connected” at the bottom of your screenshots) but data exchange doesn’t start → its hard to see why, but having a network trace could help to understand why that happens.
Only for explanation:
AsMbTCP uses internally the same configuration of the modbus master and the slave(s) then the mapping does (AsMbTCP is mroe or less the API for accessing the configured slaves by program instead of by the modules channel blocks configuration).
If you want to try a PLC configuration independent modbus tcp library, you could try using the following implementation from Github (of course, then you have to switch off modbus tcp master inside the PLC configuration):
Best regards!
Hi,
Thank you again for your response. I’m attaching a screenshot of the configuration for the ModbusTcp_any module. Regarding the network trace, I wasn’t entirely sure what you wanted to see, but I’m sending screenshots showing proper communication between Arduino - PC, and PC - PLC. However, in the case of communication between PLC - Arduino, unfortunately, I don’t see any data exchange between these devices, although both devices are active on the network (I pinged them using cmd).
Best regards.
Hi,
thanks for the traces!
It looks like, that the Arduino slave device is using the Unit Identifier 1, but the PLC queries the Unit Identifier 0.
Unit Identifiers are “Modbus device addresses” (they were used in serial based networks like RS422/RS485 to communicate to more then one slave).
I’m not sure if the Arduino slave cares about the Unit Identifier, but maybe it wants to get the right one?
So please set the Unit Identifier in your ModbusTCP_any configuration to 1, and try if something changes.
Hi,
thank you very much for all your help. Indeed, this change has brought the expected results. Sometimes, a different perspective really helps. Thanks again for your help.
Best regards
Hi Cezary,
I’m really happy that I could help, and I wish you much fun and a great success with the project!
Best regards, Alex