Jump to content

How To: DCS-BIOS RS-485 Bus with MAX485-based breakout boards


FSFIan

Recommended Posts

If you want to use an RS-485 bus to connect multiple DCS-BIOS panels through a single USB port, you will have to choose a transceiver chip. My recommendation is the MAX487: it is cheap (about $0.20 a piece) and theoretically allows up to 126 devices on a single bus without the need for bias or termination resistors (as long as the total bus length is shorter than about 12 meters).

 

However, several people have tried to use these breakout boards that are based on the MAX485 and have run into problems (unreliable transmission, resulting in garbled data or long reaction times).

I had a guess about why that happened. Now I have two of those modules on my desk and have verified my assumptions.

 

First, these are the steps you will need to take to make those modules work:

  • Make the same connections that you would for the MAX487 chip (Arduino TXO to MAX485 DI, Arduino RXI to MAX485 RO, Arduino TX_ENABLE to MAX485 DE and RE, Arduino +5V to MAX485 VCC, Arduino GND to MAX485 GND, daisy-chain the A and B pins)
  • Connect two 470 ohm resistors to one of the modules on the bus: one between A and VCC and the other between B and GND
  • On any module except the first and last ones on the bus: remove the 120-ohm resistor (marked "121" on the SMD resistor, R7 on my boards)

You can use up to six MAX485 transceiver modules (so up to five slave devices) per RS-485 bus.

 

To understand why you need to add the two 470-ohm resistors to the bus and remove the 120-ohm resistors on the devices in the middle, you need to know about termination and fail-safe biasing.

 

When an electric signal is sent over a wire, the wire behaves like a transmission line. When the signal hits the end of a transmission line, a slightly less powerful version of it is reflected back into the line and travels in the opposite direction. This reflected signal can cause the receiver to read a wrong value. It then hits the other end of the line, gets reflected again, etc. until after a few times the magnitude of the reflected signal becomes insignificantly small.

 

If the transmission line (i.e. your RS-485 bus) is short enough, this effect can be ignored (the signal finishes bouncing back and forth and the reflections die off so fast that no one notices). What is "short enough"? According to TI App Note slla070d: RS-422 and RS-485 Standards Overview and System Configurations we can use this rule of thumb:

2.1.8 Cable Termination

Cable termination is required, unless the data rate of the application is less than 200 kbps or the signal

rise/fall time at the load end of the cable is greater than four times the one-way cable delay. The latter

rule-of-thumb typically is used to describe a system that does not behave like a transmission line. In most

other applications, cable termination is recommended.

 

Electromagnetic waves in copper travel at about two thirds of the speed of light. The minimum driver rise/fall time of the MAX485 chip is 3 nanoseconds; the MAX487 has a minimum rise/fall time of 250 nanoseconds. With that information, we can calculate how long we are allowed to make the bus without using termination resistors.

For the MAX485: 3 ns * 2/3 * c / 4 = 0.15 m

For the MAX487: 250 ns * 2/3 * c / 12 = 12.5 m

 

This means that with the MAX487, we don't need to worry about termination as long as we keep the length of the bus below 12 meters, which should be the case for most home cockpits.

 

On the other hand, with the MAX485, we will need to terminate the bus, as we probably need the signal to travel more than 15 centimeters.

 

So what is bus termination? In short: we can eliminate the reflections by adding a resistor at the end of the line. Because any device on the bus can transmit, we need a termination resistor at both ends of the bus. The value of the termination resistor should be close to the characteristic impedance of the cable. The standard value for RS-485 is 120 ohm. The characteristic impedance of Cat5 cable is 100 ohm, which should still work fine with 120 ohm termination resistors.

 

Now that we have added termination resistors, we got rid of the reflections, but we have another problem. To determine whether a logic 0 or a logic 1 is being transmitted, an RS-485 transceiver looks at the difference between the voltages on the "A" and "B" lines. If it is at least +200 mV, it reads a logic 0. If it is less than -200 mV, it reads a logic 1. Anything in between -200 mV and +200 mV is undefined.

 

When one device stops transmitting on the bus and another device starts transmitting, there is a short time in between when no device is actively driving the bus into a valid value. Without termination resistors, the bus is "open circuit", i.e. the "A" and "B" lines are not connected to anything. The MAX485 and MAX487 chips guarantee that an "open circuit" bus will always read as a logic 1.

 

When we add termination resistors, a bus that is not being driven is not "open circuit" anymore: the "A" and "B" lines are connected together through the termination resistors at either end. The voltage between them will be (close to) zero volts, so the logic level is undefined and the receiver can output whatever it wants to, which will confuse the software that is trying to make sense of the received data and can cause the errors described above.

 

There is another issue: adding bias resistors influences the bus termination. If we add the bias resistors at the start of the bus, we would have to replace the 120 ohm resistor at the start with about 138 ohms for ideal results. In practice, 120 is close enough to 138 that I wouldn't bother with that.

 

The biasing resistors also present an additional load to the bus driver. Because of that additional load, we can only use 6 MAX485 chips on the bus instead of the theoretical 32. In other words, the failsafe resistors are equivalent to about 26 MAX485 receivers on the bus.

 

I got all of the information in this post from the following sources:

 

The first app note explains failsafe biasing and bus termination in detail, including schematics and equations. I have extracted the equations from that app note into a handy calculator that allows you to play with different values for termination and biasing resistors. At the end, it will tell you how many devices you can connect to the bus. A MAX485 takes up one unit load, while the MAX487 is a 1/4 unit load device.


Edited by [FSF]Ian
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thanks Ian for the very detailed description and analysis of what was happening with the RS-485 bus. Will the official DCS-BIOS documentation be updated, or even better - a Fritzing drawing of how it all comes together? Would you like any assistance with docs?

 

Cheers!

Link to comment
Share on other sites

Thanks Ian for the very detailed description and analysis of what was happening with the RS-485 bus. Will the official DCS-BIOS documentation be updated, or even better - a Fritzing drawing of how it all comes together? Would you like any assistance with docs?

 

Cheers!

 

I am working on two DCS-BIOS-related projects right now.

 

The first is what I call "DCS-BIOS 1.0". This will be DCS-BIOS as it is right now, but with a new documentation that is a) complete and b) aimed at beginners instead of programmers. This is mostly documentation work, but also requires some work on the RS-485 bus master firmware so I can give a definite answer to the question of how many RS-485 buses (2 or 3?) can be connected to a single Arduino Mega board. The new documentation will have schematics for wiring up an RS-485 bus with MAX487 transceivers.

 

The second project is "DCS-BIOS 2.0", which involves replacing the current Export.lua with the "DCS Export Core" (which only focuses on exporting data and does not know anything about the meaning of argument numbers, etc.) and replacing socat with a program written in C# that translates between DCS and the serial port. I aim to design DCS-BIOS 2.0 in such a way that features such as multi-function panels (one physical panel to control several radios, for example) or control remapping (using your A-10C pit to fly a Mig-21) can be added later on. I also want to replace the text-based command protocol (for the data that the Arduinos send to the PC) with a more efficient, binary protocol.

Link to comment
Share on other sites

Ian;3162853']I am working on two DCS-BIOS-related projects right now.

 

The first is what I call "DCS-BIOS 1.0". This will be DCS-BIOS as it is right now, but with a new documentation that is a) complete and b) aimed at beginners instead of programmers. This is mostly documentation work, but also requires some work on the RS-485 bus master firmware so I can give a definite answer to the question of how many RS-485 buses (2 or 3?) can be connected to a single Arduino Mega board. The new documentation will have schematics for wiring up an RS-485 bus with MAX487 transceivers.

 

The second project is "DCS-BIOS 2.0", which involves replacing the current Export.lua with the "DCS Export Core" (which only focuses on exporting data and does not know anything about the meaning of argument numbers, etc.) and replacing socat with a program written in C# that translates between DCS and the serial port. I aim to design DCS-BIOS 2.0 in such a way that features such as multi-function panels (one physical panel to control several radios, for example) or control remapping (using your A-10C pit to fly a Mig-21) can be added later on. I also want to replace the text-based command protocol (for the data that the Arduinos send to the PC) with a more efficient, binary protocol.

 

Thats fantastic Ian. I'm really looking forward to see what you can do with an already great project. I have already purchased a USB PCI-E expansion card and several powered 13 port hubs with the expectation I'm going to use 30+ Mini Arduino's. Would be great if I could consolidate into the mega platform using an RS-485 bus.

Link to comment
Share on other sites

Ian

 

Can you please explain cabling requirements. Can we just use any two conductor cable for "a" and "b" lines? or should we use shielded twisted pair? if so, should we ground the shield or is it not required?

 

What would be the most reliable/stable method to use?

 

Thanks

 

Clay

Link to comment
Share on other sites

You can get special cable designed for RS-485. It was designed for the same conditions as RS-485: industrial automation. It's shielded, flame- and smoke-protected, and expensive. It's also overkill for our purposes. We are not running cable over hundreds of meters and we are not running huge motors or welding robots right next to it.

 

If you are not using termination resistors, any twisted pair (shielded or unshielded) should do. If you want to use termination resistors (to handle long bus lengths or other transceiver chips), you need to know the characteristic impedance of your cable to choose a matching termination resistor.

 

I'd recommend Cat5 cable. It's easy to source, cheap, and has a known characteristic impedance of 100 ohm. Another alternative (haven't looked into it in detail, but saw it mentioned in a Hackaday article) would be XLR cable, which might be a bit easier to solder to or use with screw terminals.

 

For testing, any two conductors will do. If they are not right next to each other in a twisted pair, you lose the advantages of differential signalling (the idea being that any interference has the same effect on both conductors and will be cancelled out in the receiver when it calculates the difference between the two signals), but there will still be some margin of error.

 

Regarding the ground wire: I don't think we need a dedicated ground wire for the RS-485 bus in a home cockpit. Just make sure that all your boards are connected to the same ground via their power supply. Most people will power all boards from a single supply (e.g. a computer PSU), so that's a given. Even with separate supplies and no additional ground connection, they will probably be plugged into the same mains circuit, and the RS-485 bus would still be within spec. (Unless one of the supplies is not mains earth referenced, in which case you'd need to connect its ground to one of the others).

 

As far as I understand, the separate RS-485 ground wire becomes important in setups where the different nodes are far apart and/or may be plugged into different mains circuits (possibly even in different buildings), in which case the local ground potentials can differ by a significant amount.

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 months later...

Hello all!

I'm Maurizio from Italy and i want to share my story here because i'm almost became mad and i hope some of you will avoid it by reading!

 

I lost nearly a month trying to make the bus working ... an arduino uno (original) and a 2560 "compatible" (that's what i had handy). No succes.

No comms on the bus, no rx-tx leds working, nothing. I tried everything from removing the R7 to recalculate the bias resistors to test different twisted pairs.

No joy.

 

Today, as a last resort, i've decided to make something foolish.

I said to myself "let's swap RX with TX ... what could happen worse than not working? Fry the board? Well, be it!"

 

Surprise! Everything was working ... even without the bias resistors and with two modules with R7 still on!

 

Just imagine my face checking the circuit again and again to find the error but the error wasn't the circuit!

Finally i've found that my "compatible" arduino board has the markings (the serigraphy) of RX and TX swapped compared to an original one

So, swapping them was correct!

 

Be aware, DCS Bios fellows...madness is close!

:helpsmilie:

Link to comment
Share on other sites

  • 6 years later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...