0
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ I too more suspecting the hardware problem rather than firmware code. Because the modbus has no communication problem if using USB to serial module (FT232R). \$\endgroup\$ – Qrenz Nov 9 '18 at 0:23
  • \$\begingroup\$ How do I make the chassis grounded in a good way? Should I just twist a cable at the screw and connect it to my power supply ground? \$\endgroup\$ – Qrenz Nov 9 '18 at 1:05
  • \$\begingroup\$ @Qrenz what is your motor type? for instance, Cut the length of the wire \$\endgroup\$ – M KS Nov 9 '18 at 4:44
  • \$\begingroup\$ @M KS: brushless DC motor with gearbox 12 V, diameter shaft 28 mm. Good idea, I'll try it. \$\endgroup\$ – Qrenz Nov 9 '18 at 6:09
  • \$\begingroup\$ Rather, you should not ground the RS-485 signal ground directly against the chassis. That grounding should be much earlier down the line, where the supply ground enters the sub-system. In case of shielding though, it should be grounded against chassis in one end of the wire. \$\endgroup\$ – Lundin Nov 9 '18 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.