Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use RS485: Examples, Pinouts, and Specs

Image of RS485
Cirkit Designer LogoDesign with RS485 in Cirkit Designer

Introduction

The RS485 standard is a protocol for serial communication that allows for the implementation of multi-point systems that are robust, reliable, and can operate at high speeds over large distances. It is widely used in industrial environments for connecting various devices like sensors, controllers, and actuators, as well as in building automation, and other applications requiring multiple nodes communication.

Explore Projects Built with RS485

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!

Explore Projects Built with RS485

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!

Technical Specifications

Key Technical Details

  • Standard: TIA/EIA-485
  • Voltage Levels: Differential voltages of +1.5V to +5V for logic '1' and -1.5V to -5V for logic '0'
  • Maximum Cable Length: Up to 4000 feet (1200 meters)
  • Maximum Data Rate: Up to 10 Mbps (at shorter distances)
  • Maximum Number of Nodes: Up to 32 devices (without repeaters)

Pin Configuration and Descriptions

Pin Number Name Description
1 RO Receiver Output. This pin outputs the data received via RS485.
2 RE Receiver Enable. A low level on this pin enables the receiver.
3 DE Driver Enable. A high level on this pin enables the driver.
4 DI Driver Input. This pin inputs the data to be sent over RS485.
5 VCC Positive Supply Voltage. Typically +5V.
6 GND Ground. Reference voltage for the power supply.
7 A Non-inverting Receiver/Driver input/output.
8 B Inverting Receiver/Driver input/output.

Usage Instructions

How to Use the RS485 in a Circuit

  1. Power Supply: Connect the VCC pin to a +5V power supply and the GND pin to the ground.
  2. Connecting to a Microcontroller: Interface the DI pin to the TX (transmit) pin of your microcontroller and the RO pin to the RX (receive) pin.
  3. Enabling Communication: Use the RE and DE pins to control the mode of operation. Set both RE and DE low to enable the receiver, and set DE high (and RE low) to enable the transmitter.
  4. Termination Resistors: To prevent signal reflections, a termination resistor (typically 120 ohms) should be placed across the A and B lines at both ends of the bus.

Important Considerations and Best Practices

  • Bus Topology: Use a linear bus topology with termination resistors at each end.
  • Cable Type: Use twisted-pair cables to reduce electromagnetic interference.
  • Grounding: Ensure proper grounding to avoid potential differences between nodes.
  • Biasing Resistors: Sometimes biasing resistors are necessary to ensure a known state when the bus is idle.

Troubleshooting and FAQs

Common Issues

  • Data Corruption: This can be caused by improper termination, excessive noise, or ground potential differences.
  • No Communication: Check if the termination resistors are in place and if the RE and DE pins are being controlled correctly.

Solutions and Tips

  • Signal Integrity: Verify the integrity of the signal with an oscilloscope.
  • Cable Check: Ensure that the cables are not damaged and are properly connected to the A and B terminals.
  • Power Supply: Confirm that the power supply is stable and within the specified voltage range.

FAQs

Q: Can I connect more than 32 devices on an RS485 bus? A: Yes, but you will need to use repeaters to extend the number of allowable nodes.

Q: How can I increase the maximum distance for RS485 communication? A: Lowering the baud rate can increase the maximum cable length.

Q: What is the difference between RS485 and RS232? A: RS485 supports multi-point connections and longer distances at higher speeds compared to RS232, which is for point-to-point communication.

Example Code for Arduino UNO

#include <SoftwareSerial.h>

// RS485 control pins
const int RE_PIN = 2; // Receiver Enable
const int DE_PIN = 3; // Driver Enable

// Initialize software serial port
SoftwareSerial rs485Serial(10, 11); // RX, TX

void setup() {
  pinMode(RE_PIN, OUTPUT);
  pinMode(DE_PIN, OUTPUT);
  
  // Start serial communication
  rs485Serial.begin(9600);
  Serial.begin(9600);
  
  // Set RS485 module to receive mode
  digitalWrite(RE_PIN, LOW);
  digitalWrite(DE_PIN, LOW);
}

void loop() {
  // Check if data is available to read
  if (rs485Serial.available()) {
    int incomingByte = rs485Serial.read();
    Serial.print("Received: ");
    Serial.println(incomingByte, DEC);
  }

  // Check if data is available to send from the serial monitor
  if (Serial.available()) {
    // Set RS485 module to transmit mode
    digitalWrite(RE_PIN, LOW);
    digitalWrite(DE_PIN, HIGH);
    
    char outgoingByte = Serial.read();
    rs485Serial.write(outgoingByte);
    
    // Return to receive mode after sending
    digitalWrite(RE_PIN, LOW);
    digitalWrite(DE_PIN, LOW);
  }
}

This example demonstrates basic RS485 communication with an Arduino UNO. The SoftwareSerial library is used to create a serial port on pins 10 and 11. The RE and DE pins are controlled to switch between receiving and transmitting modes. Data received from the RS485 bus is printed to the Serial Monitor, and data entered into the Serial Monitor is sent onto the RS485 bus.