The RS485 transceiver is the linchpin for secure and high-speed data transmission, making it indispensable in today's interconnected world
A
A
Hardware Overview
How does it work?
RS485 4 Click is based on the ADM2795E, an integrated dual channel RS485 driver/receiver, with the ICoupler® isolation technology, made by Analog Devices. This integrated circuit features integrated galvanic isolation elements, providing the required isolation level. RS485 level signals are encoded into waveforms that are used to energize primary windings of the integrated transformers. At the secondary windings, the induced waveforms are decoded back into their original values and routed to the UART pins, with the appropriate TTL signal levels. The same working principle is applied in the opposite direction. This way, the digital signals are effectively conducted through the isolation barrier. Output lines are
internally routed through a set of transient filters, ESD suppressors, surge protection components, etc., replacing the complete set of commonly used external components (TVS diodes, TIPS®…). This reduces the number of reasonably expensive external protection components, cutting the time to market. There are also some other protections, such as miswiring protection, tolerance for up to ±42V on RS485 bus lines, etc. RX and TX UART lines from the mikroBUS™ are routed to RXD and TXD pins of the ADM2795E. The CS pin of the mikroBUS™ is routed to the DE pin of the ADM2795E. It is used to activate the RS485 transmission driver. Similarly, RST pin of the mikroBUS™ is routed to the RE pin of the
ADM2795E, and it is used to activate the receiver. Logic HIGH level on the DE pin activates the transmitter, and thus the UART TX session, while LOW logic level on the RE pin activates the receiver, and thus the UART RX session. The inverted logic on these pins is not a result of a random decision: they could be connected to a single point and driven by a single MCU pin: when there is a LOW level, the driver is disabled, while the receiver is enabled. This is not the case at this Click board™, as it is made for general use. However, in the case of most commonly used half-duplex communication topology, this can be very useful, reducing the number of required MCU pins.
Features overview
Development board
Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand
functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,
which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC32
MCU Memory (KB)
2048
Silicon Vendor
Microchip
Pin count
100
RAM (Bytes)
524288
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for RS485 4 Click driver.
Key functions:
rs4854_rx_disable
- Rx disable function.rs4854_tx_enable
- Tx enable function.rs4854_send_command
- Function for send command
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* \file
* \brief Rs4854 Click example
*
* # Description
* This example reads and processes data from RS485 4 clicks.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes driver.
*
* ## Application Task
* Reads the received data.
*
* ## Additional Function
* - rs4854_process ( ) - The general process of collecting presponce
* that sends a module.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "rs4854.h"
#include "string.h"
#define PROCESS_COUNTER 10
#define PROCESS_RX_BUFFER_SIZE 500
static uint8_t transmit_msg[] = "MikroE\r\n";
// ------------------------------------------------------------------ VARIABLES
// #define DEMO_APP_RECEIVER
#define DEMO_APP_TRANSMITER
static rs4854_t rs4854;
static log_t logger;
static uint8_t send_data_cnt = 8;
// ------------------------------------------------------- ADDITIONAL FUNCTIONS
static void rs4854_process ( void )
{
int32_t rsp_size;
char uart_rx_buffer[ PROCESS_RX_BUFFER_SIZE ] = { 0 };
uint8_t check_buf_cnt;
rsp_size = rs4854_generic_read( &rs4854, uart_rx_buffer, PROCESS_RX_BUFFER_SIZE );
if ( rsp_size > 0 )
{
for ( check_buf_cnt = 0; check_buf_cnt < rsp_size; check_buf_cnt++ )
{
log_printf( &logger, "%c", uart_rx_buffer[ check_buf_cnt ] );
}
}
}
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
rs4854_cfg_t cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
rs4854_cfg_setup( &cfg );
RS4854_MAP_MIKROBUS( cfg, MIKROBUS_1 );
rs4854_init( &rs4854, &cfg );
#ifdef DEMO_APP_RECEIVER
rs4854_re_pin_set( &rs4854, RS4854_PIN_STATE_LOW );
rs4854_de_pin_set( &rs4854, RS4854_PIN_STATE_LOW );
#endif
#ifdef DEMO_APP_TRANSMITER
rs4854_re_pin_set( &rs4854, RS4854_PIN_STATE_HIGH );
rs4854_de_pin_set( &rs4854, RS4854_PIN_STATE_HIGH );
#endif
}
void application_task ( void )
{
#ifdef DEMO_APP_RECEIVER
rs4854_process( );
#endif
#ifdef DEMO_APP_TRANSMITER
rs4854_generic_write( &rs4854, &transmit_msg[ 0 ], 8 );
Delay_ms( 2000 );
#endif
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END