Electrical – ModBus Timeout Error

embeddedmicrocontrollermodbuspicrs485

Anyone very experienced with Modbus & RS-485???

My task is to control a DC motor using micro PIC24.
The motor setting like the angle, delay, start/stop, duty cycle, etc will be sent from PC using Modbus to PIC24.

The system is like this:

PIC24 -> UART -> IC MAX3471 -> RS-485 to RJ-45 converter -> RJ-45 to USB -> PC (running modbuspoll tool)

The Modbus format used is Modbus RTU.

At first, the Modbus read holding register function and write single register function is working. But after I send some of the motor settings using Modbus write single register function then the motor start running, it was then the Modbus communication always timeout error.

And once the timeout error happens, the next time I turn on the system again it will keep giving timeout error.
enter image description here
I've tried changed UART baud rate from 9600 to 115200.
Try changing the RS-485 to RJ-45 converter board (just in case it broke), the phenomena just repeat.

Can someone give me some advice on what could be the possible cause?

Also, I'm not sure about this, in Modbus RTU format, at the start and end there should be 28 bit (at least 3 1/2 character length), but should the micro firmware code care about this since at the PC use modbuspoll tool?

I've tapping the A & B signal using logic analyzer, if I send some character from uC to RS-485 (but not connected to PC), the character showing correctly on A & B line. But if I tapping the A & B line signal when I send read holding register function from PC using modbus poll (give timeout error) I got some weird signal:

enter image description here

So it seems the problem is not in the uC firmware code, but rather either one of them: USB to RS-485 converter, straight ethernet cable, or RS-485 interface board.
Here's the USB to RS-485 converter that I used:
enter image description here

and the RS-485 interface board:
enter image description here

Best Answer

In some cases staring a motor or any high-power devices generate noise on grounding signal. If you don't have good chassis ground and shielding this affects your signal.

for debugging: 1) run your controller without heavy load, just check controller with a led or any small load, after setting that led on/ off, if you have a problem then you have a problem with code and implementation.

2) if you don't have a problem in the first step, you should check the grounding and chassis ground

recommendation: if you work with high voltage load, for safety it's better to use an isolated USB_to_485 module.