Mega2560 master on RS485 bus stops communicating with VFD when I add another RS485 module

Thread Starter

matthijsvhest

Joined Aug 14, 2018
4
I’m doing a project where I’m building a control panel for a VFD (inverter/variable frequency drive). I’m connecting the two over half duplex RS485 and use Modbus RTU. As a master I use a Arduino Mega 2560 with a TTL to RS485 module. Yes the VFD and the Mega are correct baud rates (9600) and pairity (8N1), it works if the master and VFD are the only devices on the bus. But when I add another slave (Arduino nano) with this TTL to RS485 module (even without a microcontroller nad no code) the communications seems to be broken.

I’m using a shielded twisted pair wire of about 3 metres to a circuit board daisy-chaining the module for the nano (10cm) and the VFD (1 meter).

What did I try?

I started with the mega as master, nano as slave, and the VFD as slave. Because I did not know the extra module on the bus was causing the problem at this point I was wondering if it was my code or hardware setup. I’ve read multiple topics of people having trouble with the Mega and the RS485 module but never got to the exact problem or a solution. I need the mega for the scale of my control panel so I kept digging.

About code

I use modbusmaster (see example of halfduplex on the github) and then just 2 lines of code writing to single register (0x2000, 0x0006 for example) just as a simple test to start/stop the VFD. Worked before when testing the VFD and an UNO as the only two devices on the bus, why not now? The nano slave does not have any code at this point to rule out any software issues interfering. I tried flushing as well, did not solve the problem.

Back to hardware troubleshooting

So I tried the same setup with another nano as a master instead of the mega (leaving the other nano as slave connected). It works! But I need the Mega… So I started looking into things. I tried hardware serial, altserial and softwareserial. None worked. Then I started questioning the lines, nothing that was having short-circuits or big interference (doing this in my living room, not on an industrial site). When I pulled out the module for the nano slave and it started to work with mega as master and the VFD as only slave connected.But hell why, I need the nano slave to be on the bus as well!

Trying termination resistors

So I desoldered R5 to R7 (termination resistors) of the extra module, which helps for some people. Leaving the module of the mega as is. Same situation, communication is fine until I drop in the module for my nano slave.

Making the nano slave repeat works??!

I also experimented with the communication between the mega master and the nano slave, that works! But the VFD will not listen to the master. When I programmed the nano slave to repeat what it hears (yes, like a parrot) then the VFD is responding correct with the setup I want (master, VFD slave, nano slave). But the nano slave should not be the one acting as a master, let alone repeat a message on the bus. The weird thing here is, the VFD is not responding to the message of the master, but the nano picks it up and is able to repeat it so the communication IS correct somehow, but not good enough for the VFD?? I'm really freaking out now.. I can't sleep anymore! please help.

Other ideas

I do admit, I have grounded the shield of the 3 meter cable on both ends, but this should not be the problem, it works with just a master and the VFD as slave setup so why not when adding another module for the nano as slave.

The line is now measuring 120 ohm resistance (comes from the TTL to RS485 module on the Arduino Mega side). The VFD has a jumper, on position is 18,2 kOhm and off position is 500 ohm. Due to the parallel connection no matter what position the line resistance between A and B stays on or around 120 ohm. The problem just occurs when attaching the extra module for the nano slave, even when I leave out the slave itself.

Anyone out there who might be able to help me troubleshooting this? Anything I don’t know of? (Yes my first RS485/Modbus application, but doing good so far I guess).

Should I desolder the termination resistors of the other module as well? Any other ideas on why the communication would be broken when I throw in another module?

If anything is unclear, please tell me. I tried my best to clarify the setup and what I tried. Again, code does not seem to be an issue here.
 

dendad

Joined Feb 20, 2016
4,481
Yes, you do need to ground all the shields both ends so all the units share a common 0V potential. I've fallen into that trap of just using 2 wires and found the different unit's power supplies do not have their 0V at the same potential. So the common mode voltages can be way outside the limits of the RS485 drivers so they fail to work.
Next, make sure the slave units have all their RS485 drivers listening, not in TX mode. I've always just connected the RE and DE pins together as one is inverted with respect to the other, that way, only one control line is needed for R/TX switching.
It sounds like your extra unit was in TX mode. Only one device should transmit at a time.
 

Thread Starter

matthijsvhest

Joined Aug 14, 2018
4
Not true, the shield should be connected to the ground on just one side, preventing any ground loops. I did connect it on both sides, therefor mentioning it as it might play a role in the issue. Besides the A and B line I do have a ground wire as well, not using the shield for that... that would eb stupid, (using 2x2 shielded).

As I replied to my own topic, the problem was in the DE/RE signal. I left it floating, without microcontroller or without code makes it high due to the pull-up resistor. This makes it go in transmit mode, blocking the rest of the bus. I do have these pins together as well, as the RE_NEG is actually inverted which makes this possible.

So yes the problem was having the module in transmit mode, but I already figured that out. Has nothing to do with the ground.
 

dendad

Joined Feb 20, 2016
4,481
Not true, the shield should be connected to the ground on just one side, preventing any ground loops. I did connect it on both sides, therefor mentioning it as it might play a role in the issue. Besides the A and B line I do have a ground wire as well, not using the shield for that... that would eb stupid, (using 2x2 shielded).
That is what I thought too. BUT, it only works if you have both 0V supplies at the same (or close) voltages. You have a ground wire so in that case it is true. Without a common 0V connection, the shield can be used as there will not be a ground loop then. It is best to have a common ground and shield connected at one end, but in real life installations, often the units are far apart and have separate power supplies so the common mode problem is quite severe.

These units are very useful, and not very expensive....
https://www.mornsun-power.com/html/product/RS-485-Transceiver-Module.html
My only gripe was the sense of the T/Rx switching is inverted on the modules I used. It may be different in other versions.
Having opto isolated networking solves a lot of problems. Mornsun have a great range.

I wish we had them years ago when we did an RS485 network in a wire drawing mill. Back then we ran 2 wire networks and when the big motors started up, the mains bounce via the earths drove the network silly.
 
Last edited:

Thread Starter

matthijsvhest

Joined Aug 14, 2018
4
That is what I thought too. BUT, it only works if you have both 0V supplies at the same (or close) voltages. You have a ground wire so in that case it is true. Without a common 0V connection, the shield can be used as there will not be a ground loop then. It is best to have a common ground and shield connected at one end, but in real life installations, often the units are far apart and have separate power supplies so the common mode problem is quite severe.

These units are very useful, and not very expensive....
https://www.mornsun-power.com/html/product/RS-485-Transceiver-Module.html
My only gripe was the sense of the T/Rx switching is inverted on the modules I used. It may be different in other versions.
Having opto isolated networking solves a lot of problems. Mornsun have a great range.

I wish we had them years ago when we did an RS485 network in a wire drawing mill. Back then we ran 2 wire networks and when the big motors started up, the mains bounce via the earths drove the network silly.
Now you're being specific enough :p I use a common ground as mentioned before, and still connected both ends of the shield. That's why I talked about it. No discussion needed, just thought you was wrong, but you just didn't tell the whole story :)

How dare people have multiple power supplies without a common ground..

It sounds like you know what you are doing, I was just surprised that someone replied when I solved the issue already, with a story a bit vague :p
 
Top