I'm trying to use an Arduino Mega2560 as a sort of Modbus pass-through to be able to communicate with a device that is not quite behaving properly. Essentially I have a slave device whose ID is 7, and when I poll slave ID 7 (using Modbus Poll and the MultiSerialMega code) I have no problem communicating. The issue with the slave is that it will send I response even if I don't poll it's address. For instance, I have two other slaves, ID's 1 and 2, and they are connected to the master on the same line as the slave 7 device. When I try to poll slaves 1 or 2, slave 7 still sends a response and it's hogging the bus causing communication errors with slaves 1 and 2.
I was wondering if it would be possible to use the Mega2560 as a master that would only pass-through responses from the appropriate slave. I have two RS485 shields, and I was wondering if I could send data via one serial bus and receive data via another, using the two shields, and somehow control the responses so that only those from the polled slave would pass through. I have checked out the SimpleModbus libraries, as well as the Modbus-RTU libraries by jpmzometa, but I am not sure how to modify the code to enable this kind of pass through. Is it even possible?
I'm pretty new to Arduino (and Modbus for that matter), so hopefully this all makes sense. Thanks for any help you can provide!
It would be best to first try and establish why slave 7 is responding without an request.
When using Modbus Poll connected only to slave 7 does the slave still respond without an request?
Using QModbus you can see this easily by viewing the receive frame on the right.
Are you using 680ohm tie up and down resistors to pull the communication lines to a known logic when the bus is inactive?
Are you using a 120ohm termination resistor on both sides?
To be sure, I would much rather isolate the problem without using the Arduino as a passthrough. It just seemed like a last ditch attempt.
When using Modbus Poll, you can view the communications display, which clearly shows a response attempt by slave 7 regardless of which slave is polled. I tried using a 100Ohm resistor jumped across both termination ends but I didn't try the 680Ohm tie up/down resistors. They weren't necessary when polling only Slaves 1 and 2 without 7 in the loop, so I figured it wasn't an issue. Maybe that will help. I'll give it a shot and report back. Thanks.