0
\$\begingroup\$

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.

UPDATE

setup

schematic of the converter

converter schematic

Hope this helps

\$\endgroup\$
  • 1
    \$\begingroup\$ You'll have to be clearer about what the failure mode is, perhaps by first investigating that. What state is the code in? Is it not transmitting? Is it transmitting but being ignored? Are collisions happening? With just two wires you should be able to hook up an RS485 converter to an ordinary UART and log everything from everybody, parse it and see if it makes sense. \$\endgroup\$ – Chris Stratton Aug 14 '18 at 15:02
  • \$\begingroup\$ I tested the communication between master mega and slave nano, it is sending and receiving. But the VFD will only act on commands when the slave nano is diconnected from the bus, or when I let the nano slave repeat the message from the master mega. The RS485 converter is connected to UART. \$\endgroup\$ – Matthijs van Hest Aug 14 '18 at 15:05
  • 1
    \$\begingroup\$ Again, you need to figure out what is happening when the system fails. Setup something to capture all traffic on the wire (like an additional RS485 converter connected to a USB UART and PC for receive only monitoring) and write scripts to interpret that. Give your master some additional status outputs... Also make sure that you only have termination resistors at the physical ends of the line, nowhere else. \$\endgroup\$ – Chris Stratton Aug 14 '18 at 15:06
  • 1
    \$\begingroup\$ The fact that you even tried module in the middle with termination resistors tells me that there could be more wiring problems in your setup. You need to post complete wiring diagram and links to the adapter modules you use if you want to get meaningful help. \$\endgroup\$ – Maple Aug 14 '18 at 15:21
  • 1
    \$\begingroup\$ For the third time, you need to figure out how. Either buy a scope and probe the lines, or rig up something to let you see what is going on, like the previously mentioned outputs from your master or PC based scheme for snooping the entire bus. And make sure that when you have your "without code" module in there, you've wired the transmit enable inactive and not merely left it floating. \$\endgroup\$ – Chris Stratton Aug 14 '18 at 15:40
3
\$\begingroup\$

You (or whoever made this dubious module) have erroneously wired the transmit enable pin with a pullup resistor. Without code configuring a corresponding MCU pin as an output and driving it low, that RS485 transceiver will jam the bus.

You should correct your schematic symbol to show the logical sense of the enables - DE is active high and /RE is active low. Then change your circuit to default them safely.

If you're going to keep using this defective module as is, you'll have to be sure that the DE pin is always kept low, except at the proper time for that node to transmit.

\$\endgroup\$
  • \$\begingroup\$ Never paid enough attention to the DE/RE signal... Left it floating or connected to a pin not doing anything, or as you mentioned it gets pulled-up. It woks now.. I feel so incredibly stupid. Did not look closely to the schematic yet as I didn't think it would be a problem. And the 2 nano's setup was working .. still weird to me (maybe I did have code then.. idk) \$\endgroup\$ – Matthijs van Hest Aug 14 '18 at 15:59
  • \$\begingroup\$ I feel stupid, but it's good to have someone else looking at it to catch these small errors ... Thanks \$\endgroup\$ – Matthijs van Hest Aug 14 '18 at 16:03
  • \$\begingroup\$ You can leave RS485 receivers enabled if your code can ignore hearing itself talk; but you have to actively manage the transmit enable, using it only when it is your turn to talk - that goes for all devices on the bus, not just this extra one. \$\endgroup\$ – Chris Stratton Aug 14 '18 at 16:23
  • \$\begingroup\$ I understand. Thanks again. Never thought this would block the whole bus, despite there is no extra message being send. \$\endgroup\$ – Matthijs van Hest Aug 14 '18 at 16:55

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.