How does it work?
RS485 Click 5V is based on the ADM485, a low-power EIA RS-485 transceiver from Analog Devices. It is a tristate differential line driver and differential input line receiver intended to be used as a physical layer device, often called PHY, providing physical interfacing of the MCU TTL level UART lines with the RS422/485 bus. It is well suited for transmitting smaller data blocks over long distances, using a twisted differential signal pair for both TX and RX signals, allowing for half-duplex asynchronous communication. The ADM485 transceiver consists of separate driver and receiver sections, with Driver Enable and Receiver Enable pins used to enable the appropriate sections. The driver section drives the RS422/485 bus with the signal received on the UART RX line, while the receiver section returns data from the bus to the MCU via the UART TX line.
RS422/485 standard only specifies the electrical characteristics of the transmitter and the receiver. It does not specify or recommend any communications protocol, only the physical layer. The top layer communication protocol of choice, such as the MODBUS or similar protocols, can be used. Therefore, RS485 click 5V offers UART RX and TX pins routed to the appropriate mikroBUS™ TX and RX UART pins. The MCU uses these pins to send data to the RS485 bus in a form determined by the user protocol.
The ADM485 IC allows communication with data rates up to 5 Mbps. However, the bus length determines the maximal transfer speed: longer bus lines will result in less transfer speed. The RS422/RS485 bus needs to be terminated with the resistor on both ends (so-called parallel termination), which is equal to the characteristic impedance of the used cable, to prevent line reflections. The RS485 standard prescribes using a twisted pair cable as the data bus. Twisted pair cable tends to cancel common-mode noise and cause cancellation of the magnetic fields generated by the current flowing through each wire, thereby reducing the effective inductance of the pair.
The Click board™ is equipped with a jumper that can be used to route the termination resistor of 120Ω between the bus lines. It is also equipped with two more jumpers, labeled as BIAS ENABLE. These jumpers enable bus biasing by using pull-up and pull-down resistors between the bus differential lines and VCC/GND, respectively, preventing certain faulty conditions when no drivers are enabled on the bus, in addition to existing IC protection.
RS485 Click 5V uses a standard 2-Wire UART interface to communicate with the host MCU with commonly used UART RX and TX lines. Receiver output enable (RE) and driver output enable (DE) pins of the ADM485 are joined together and routed to the R/T pin of the mikroBUS™ socket. When left floating, a pull-down resistor determines the states on these pins, so you have to enable the device by writing a High logic state. Note that DE and RE pins use opposite signal polarities for the active state, making it possible to drive them with a single MCU pin. When a HIGH logic level is applied to the R/T pin, the transmitter becomes activated, while the receiver is deactivated at the same time – and vice versa. The R/T pin acts as a communication direction pin in this configuration.
This Click board™ can be operated only with a 5V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.
Specifications
Type
RS485
Applications
Board is suitable for Low power RS-485 systems, DTE/DCE interface Packet switching, Local area networks (LNAs), Data concentration, Data multiplexers, Integrated services digital network (ISDN) and more.
On-board modules
ADM485ARZ differential line transceiver
Key Features
Meets EIA RS-485 standard; 5 Mbps data rate; Short-circuit protection
Interface
GPIO,UART
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
M (42.9 x 25.4 mm)
Input Voltage
5V
Pinout diagram
This table shows how the pinout on RS485 click 5V corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
LD1 | PWR | – | Power LED indicator |
J2 | BIAS ENABLE | – | Pull-up resistor enables the positive bus line (non-inverted line) |
J3 | BIAS ENABLE | – | Pull-down resistor enables the negative bus line (inverted line) |
J4 | TERM | – | Termination resistor enable |
RS485 click 5V electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | – | 5 | – | V |
Bus Common Mode Range | -7 | – | 12 | V |
Data Rate | – | – | 5 | Mbps |
Software support
We provide a demo application for the RS485 click 5V click on our LibStock page, as well as a demo application (example), developed using MIKROE compilers. The demo can run on all the main MIKROE development boards.
Library Description
Library initializes and defines a GPIO driver and performs control of device voltage.
For more details check the documentation.
Key functions:
void rs485_writeByte(uint8_t input)
- Write Single Byte.uint8_t rs485_readByte()
- Read Single Byte.uint8_t ras485_byteReady()
- Check for new byte received.
Example description
The application is composed of three sections:
- System Initialization - Initializes UART module.
- Application Initialization – Driver intialization.
- Application Task – (code snippet) – Checks if new data byte has been received in the RX buffer (ready for reading), and if it has then it reads one byte from the RX buffer. Otherwise, the application task writes the message data via UART.
void applicationTask() { char tmp; uint8_t rdyFlag; // RECEIVER - UART polling rdyFlag = rs485_byteReady(); if (1 == rdyFlag) { tmp = rs485_readByte(); mikrobus_logWrite( &tmp, _LOG_BYTE ); } // TRANSMITER - TX each 2 sec for (tmp = 0; tmp < 9; tmp++) { rs485_writeByte( MESSAGE_DATA[tmp] ); mikrobus_logWrite( "MESSAGE SENT", _LOG_LINE ); } Delay_ms(2000); }
The full application code and ready to use projects can be found on our LibStock page.
Other MIKROE Libraries used in this example:
- UART
Additional notes and information
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MIKROE compilers, or any other terminal application of your choice, can be used to read the message.