Description
The MAX485 TTL To RS485 Module converts TTL signal to RS485 for long range, high data rate error prone differential communication. Digital communications networks implementing the EIA-485 standard can be used effectively over long distances and in electrically noisy environments.
Multiple receivers may be connected to such a network in a linear, multi-drop configuration. These characteristics make such networks useful in industrial environments and similar applications.
This converter lets you send and receive data using the RS485 network from your Arduino /microcontroller. Similar to Serial TTL and RS232 interfaces, the RS485 lets you transfer data between microcontrollers and devices but with extra features! RS485 is an industry standard protocol for data transfer and provides numerous advantages.
It lets you transfer data between up to 32 devices, through the same data line over a cable length of up to 1.2km (4000ft) with a maximum data rate of 10Mbit/s. This converter is designed for office and industrial applications (non-isolated) and provides superior characteristics/features normally found only on more expensive units.
Features :
- On-board MAX485 chip, A low power consumption for the RS-485 communication, slew-rate limited transceiver.
- A low power consumption for the RS-485 communication
- Onboard then 5.08 (mm) pitch 2P terminal to facilitate RS-485 communication wiring.
- Slew-rate limited transceiver
- All pins of the chip have been lead to can be controlled through the microcontroller.
- Convenient RS-485 communication wiring
- Multiple Units can be connected to the same RS-485 bus wiring.
- All Chip pins are brought out for proper controls
SPECIFICATION
IC Chip | MAX485 |
Operating Voltage (VDC) | 5 |
Length (mm) | 45 |
Width (mm) | 15 |
Height (mm) | 14 |
Weight (gm) | 4 |
Getting started with the MAX485 TTL To RS485 Module
In this tutorial you will learn how to use two modules Max485 TTL to RS485 to communicate with each other one as a slave while other as a master. Master will send a signal to a slave device and slave is there to receive a signal from Master. You can consider it as a simplex communication
Hardware required
- Arduino UNO x2
- Max485 TTL to RS485 Module x2
- Jumper wires
How a Max485 to RS485 Module Works
RS485 provides for robust serial communications over long distances of up to 1200 meters and in electrically noisy environments and is commonly used in industrial environments. It supports up to 2.5MBit/Sec data rates, but as distance goes up, the maximum data rate that can be supported comes down. You can think of RS-485 as RS232 on steroids. The data starts out as typical TTL level serial as far as the microcontroller is concerned while the RS-485 module takes care of converting the electrical signals between TTL and the differential signaling used by RS-485.
Connecting the Hardware
Upload the sketch for Master
/*
* RS485 Master Software
* Exercise the MAX485 Module. This code runs on the first (Master)device.
* Use the RS485_Slave_Test software for the second (Slave) device
* This uses the SoftSerial.h library which comes with the Arduino IDE
* Pins used for the soft serial port are fairly arbitrary and can be changed
* as needed. Just redefine them below.
*/
#include <SoftwareSerial.h>
const int SSERIAL_RX_PIN = 10; //Soft Serial Receive pin
const int SSERIAL_TX_PIN = 11; //Soft Serial Transmit pin
const int SSERIAL_CTRL_PIN= 3; //RS485 Direction control
const int LED_PIN = 13;
const int RS485_TRANSMIT = HIGH;
const int RS485_RECEIVE = LOW;
// Create Soft Serial Port object and define pins to use
SoftwareSerial RS485Serial(SSERIAL_RX_PIN, SSERIAL_TX_PIN); // RX, TX
int byteReceived;
//===============================================================================
// Initialization
//===============================================================================
void setup()
{
Serial.begin(9600); // Start the built-in serial port
Serial.println(“Master Device”);
Serial.println(“Type in upper window, press ENTER”);
pinMode(LED_PIN, OUTPUT); // Configure any output pins
pinMode(SSERIAL_CTRL_PIN, OUTPUT);
digitalWrite(SSERIAL_CTRL_PIN, RS485_RECEIVE); // Put RS485 in receive mode
RS485Serial.begin(9600); // Start the RS485 soft serial port
}
//===============================================================================
// Main
//===============================================================================
void loop()
{
if (Serial.available()) // A char(byte) has been entered in the Serial Monitor
{
byteReceived = Serial.read(); // Read the byte
digitalWrite(SSERIAL_CTRL_PIN, RS485_TRANSMIT); // Put RS485 in Transmit mode
RS485Serial.write(byteReceived); // Send byte to Remote Arduino
delay(1); // Wait before going back to Receive mode
digitalWrite(SSERIAL_CTRL_PIN, RS485_RECEIVE); // Put RS485 back into Receive mode
}
if (RS485Serial.available()) //Data from the Slave is available
{
digitalWrite(LED_PIN, HIGH); // Show activity on LED
byteReceived = RS485Serial.read(); // Read received byte
Serial.write(byteReceived); // Show on Serial Monitor
delay(10);
digitalWrite(LED_PIN, LOW); // Turn LED back off
}
}
Upload the sketch for Slave
/*
* RS485 Slave Software
* Exercise the MAX485 Module. This code runs on the second (slave)device.
* Use the RS485_Master_Test software for the first (Master) device
* This uses the SoftSerial.h library which comes with the Arduino IDE
* Pins used for the soft serial port are fairly arbitrary and can be changed
* as needed. Just redefine them below.
*/
#include <SoftwareSerial.h>
const int SSERIAL_RX_PIN = 10; //Soft Serial Receive pin
const int SSERIAL_TX_PIN = 11; //Soft Serial Transmit pin
const int SSERIAL_CTRL_PIN = 3; //RS485 Direction control
const int LED_PIN = 13;
const int RS485_TRANSMIT = HIGH;
const int RS485_RECEIVE = LOW;
// Create Soft Serial Port object and define pins to use
SoftwareSerial RS485Serial(SSERIAL_RX_PIN, SSERIAL_TX_PIN);
int byteReceived;
int byteSent;
//===============================================================================
// Initialization
//===============================================================================
void setup()
{
Serial.begin(9600); // Start the built-in hardware serial port
Serial.println(“Slave Device”);
pinMode(LED_PIN, OUTPUT); // Configure any output pins
pinMode(SSERIAL_CTRL_PIN, OUTPUT);
digitalWrite(SSERIAL_CTRL_PIN, RS485_RECEIVE); // Put RS485 in receive mode
RS485Serial.begin(9600); // Start the RS485 soft serial port
}
//===============================================================================
// Main
//===============================================================================
void loop()
{
// Watch for data coming in on the soft serial port. If found, send a copy to the
// hardware port to display on the local serial terminal and also echo a copy back out
// the soft serial port to the Master device
if (RS485Serial.available()) // If data has come in from Master
{
byteSent = RS485Serial.read(); // Read the byte
Serial.write(byteSent); // Show on local Serial Monitor window
digitalWrite(LED_PIN, HIGH); // Show activity on LED
delay(10);
digitalWrite(SSERIAL_CTRL_PIN, RS485_TRANSMIT); // Put RS485 in Transmit mode
RS485Serial.write(byteSent); // Send the byte back to Master
delay(1); // Wait before going back to Receive mode
digitalWrite(SSERIAL_CTRL_PIN, RS485_RECEIVE); // Put RS485 back into Receive mode
digitalWrite(LED_PIN, LOW); // Turn LED back off
}
}
Testing the circuit
Upload the program to the Arduino board and then open the serial monitor. If it works correctly you should get the following result on the serial monitor.
1.Master Serial Monitor (Sender)
Slave Serial Monitor (Receiver)