Up to 3 RS485 Busses on One Arduino

by Zihatec in Circuits > Arduino

2501 Views, 4 Favorites, 0 Comments

Up to 3 RS485 Busses on One Arduino

stacked.png
isolation.png

In this instructable I will show how to connect up to 3 independent RS485 busses to one Arduino. This can be useful if you want to create a gateway between these busses or if you want to control devices in these busses (without to connecting the busses itself). Another application is the connection of a RS422 device (for example motor control) and a RS485 device (for example a sensor) to the same Arduino.

In any case you will need a RS485 shield with isolated interface to eleminate grounding problems and to protect the Arduino.

Tools & Materials

RS422 RS485 Shield for Arduino

Hardware:

Software:

  • Arduino IDE

DIP Switch & Jumper Setting for BUS 1

IMG_20180907_092256.jpg

Jumper:

  • UART RX to position 0
  • UART TX to position 1
  • Voltage to position 5V

DIP Switch:

  • S1 = OFF - ON - ON - OFF
  • S2 = OFF - OFF - ON - ON
  • S3 = ON - OFF - OFF - OFF

DIP Switch & Jumper Setting for BUS 2

IMG_20180907_091507.jpg

Jumper:

  • UART RX to position 2
  • UART TX to position 3
  • Voltage to position 5V

DIP Switch:

  • S1 = OFF - ON - ON - OFF
  • S2 = OFF - OFF - ON - ON
  • S3 = ON - OFF - OFF - OFF

DIP Switch & Jumper Setting for BUS 3

IMG_20180907_091619.jpg

Jumper:

  • UART RX to position 4
  • UART TX to position 5
  • Voltage to position 5V


DIP Switch:

  • S1 = OFF - ON - ON - OFF
  • S2 = OFF - OFF - ON - ON
  • S3 = ON - OFF - OFF - OFF

Software Integration

The shield for bus 1 will use the hardware UART on PIN 0 and 1 of the Arduino. The both other shields will use software UARTs.

#include <SoftwareSerial.h>

SoftwareSerial RS485_BUS2(2,3);

SoftwareSerial RS485_BUS3(4,5);

void setup()

{

....

// init serial port for bus 1

Serial.begin(9600);

// init serial port for bus 2

RS485_BUS2.begin(9600);

// init serial port for bus 3

RS485_BUS3.begin(9600);

....

The transmittion data of these software UARTs is limited by the calculation power of the Arduino. Of course if you will use an ARM based Arduino or STM32 board this will not be really a problem, but for the UNO it is recommend to use only two shields at the same time and for the second shield not more as 9600 Baud as data rate.