Interface one pair of rx/tx with multiple rs485 chips


I am working on a project where I have one master arduino that communicates(rs485) with multiple (50 approx) atmega48 based slaves. I am planning to partition the 50 slaves into 10 partitions (5 each) and connect them to 10 rs485 networks. The master therefore has to interface with 10 RS485 chips.

I considered softserial, but we are dealing with an atmega328 and 10 rs485 chips; the pins wouldn't be sufficient.

I am under the impression that this can be achieved by using a dual channel analog multiplexers/demultiplexers:

e.g., 2 Sparkfun's single channel Mouser has a wide range.

I would like to connect the RX and TX pins of the master to a dual channel 1:16 mux/demux; with the other ends connected to ten RS485 chips. In this way, I can have my chip select lines select the mux/demux before I send "and" receive the messages.

I don't see any theoretical hurdles here; I am an electronics newbie though. Does this work? Are there any better alternatives....?

Any advice is highly appreciated..


First question, why the partition into 10 networks? You can run all 50 off a single cable.

Assuming you really need to do this you can control the DE and RE pins on each transceiver, so you shouldn't need the mux.


This is an extension to the slave design that was discussed earlier: (,66042.0.html).

The idea here is that the 50 slaves sleep all the time (there by saving power), occasionally waking up whenever they receive a "wake up" broadcast through the rs485. The master broadcasts a "wake up" followed by the id of the slave that it wishes to instruct; at that point, all the other slaves (expect that one that the master chooses) go to sleep. The master instructs the selected slave to do whatever (2-3 sec operations); slave executes the instruction and replies back the results (all the sleeping slaves will wake up, examine the message and go to sleep immediately).

Now, as you can see, the master wakes up 50 slaves whenever it wishes to communicate to one slave and the slave inturn wakes up all the other slaves whenever it reports its results back to the master. On an average, I am expecting that the master interacts with every slave atleast once every minute; there will be a lot of unnecessary wake-up/sleep cycles. This undermines the energy efficiency.

I was thinking that if I partition that 50 slaves into 10 rs485 partitions I should be able to reduce the number of times each slave wakes up within a minute. Yes, we will be dealing with 10 rs485 instead of one, but I feel that its a much cleaner approach.

So, if we use a digital mux to control the DE and RE pins of the 10 RS483 chips, we can select the channel through which we can send the messages... right? I need to test this; setting up a simple test bed with 3 or 4 rs485s will in itself take a while.

So, if we use a digital mux to control the DE and RE pins of the 10 RS483 chips, we can select the channel through which we can send the messages... right?

That's about right, a decoder might be more appropriate, something like a 74xx138 or 74xx154, but a mux will do the same job. Trouble is you have to set DE and RE to opposite levels so you need twice the number of decoders or some inverters.

I suppose then that this is the same chip count as just using muxes for the RX and TX data.


I have choosen an active high decoder and an active low decoder: 74HCT154 (active low) -> connected to RE (bar) 74HCT4514 (active high) -> connected to DE

... the idea here is that by default, the RE(bar) will be set to high and the DE will be set to low. Now, whenever the correct rs485 is choosen to be written into, its DE will be set to high. Similarly, the RE(bar) will be set to low whenever something needs to be read from the RS485. I am hoping that this is going to work (it seems to be simple... atleast for me :-))

  1. Since I am connecting as many as 10 (or may be even 16) maxium's max485s to the arduino's RX and TX pins, should I worry about noise?

Moreover, at somepoint in the future, this board that I am making will be placed near a power supply something similar to this:

As a matter of fact, this power supply will be connected to the arduino. 2. Does it make sense to attach two 100K pull down resistors to both TX and RX to prevent noise? 3. Does the power supply induce any electrical noise into the Rx and TX pins? 4. What is the best way to insulate RX and TX pins?... I am open to the idea of having 4-6 layers within the board and dedicating two layers to RX and TX.

Any advice is highly appreciated... thanks.

There is a good chapter about noise in digital circuits in this book:

I will be going through it for the next couple of days.... any pointers about noise and interference to RX & Tx that I should specifially look for will be highly appreciated. thanks,

As I understand it you will always have one hard connection at a time into the Arduino so there shouldn't be any issues with the RX signal, OTOH there may be small glitches as you change channels so a pull up on RX may not be a bad idea.

I would organize the address control lines for the decoders so they are on a single port and can therefore be all set with a single instruction (don't use digitalWrite()). That way there's no long period when you have a floating connection or the connection is bouncing between lines because you are setting addresses over several instructions. EG

digitalWrite (addr0pin, a); digitalWrite (addr1pin, b); digitalWrite (addr2pin, c); digitalWrite (addr3pin, d);

Will cause all sorts of addresses to be momentarily selected, whereas

PORTB = x;

does all the pins at the same time.

I would also flush the UART RX buffer after changing channels just to be sure, and the code running on the mega48 slaves should be robust in regard to transients on the line. This implies a reasonable protocol with error checking is in place.

The RS485 lines should have what they call "failsafe" termination (~560R pullup on A and pull down on B) because they will be in a hi-Z state for much of the time and floating lines will have noise issues. Many (most?) transceivers these days have built-in fail safe I think but I'd still do it externally with resistors.

As for the power supply, I haven't looked at the specs for it (no data left on my plan until tomorrow) but I would not expect it to cause problems, RS-485 is designed to handle such things and it shouldn't have any affect on your logic.