The core purpose of this solution is to establish a robust, long-distance network, facilitating efficient data exchange
A
A
Hardware Overview
How does it work?
RS485 5 Click is based on the MAX485, low-power, slew-rate-limited transceiver for RS-485 and RS-422 communication from Analog Devices, which draw between 120µA and 500µA of supply current when unloaded or fully loaded with disabled drivers. All parts operate from a single 5V supply. Driver is short-circuit current limited and is protected against excessive power dissipation by thermal shutdown circuitry that places the driver outputs into a high-impedance state. The receiver input has a fail-safe feature that guarantees a logic-high output if the input is open circuit. The MAX485 slew rates are not limited, allowing it to transmit up to 2.5Mbps and half-duplex communication. In general, the maximal transfer
speed is determined by the bus length, longer bus lines will result in less transfer speed. The RS485/422 line should be terminated at both ends in its characteristic impedance and stub lengths off the main line should be kept as short as possible to minimize the reflections. The RS-485/RS-422 standard covers line lengths up to 1220 meters (4000 feet). Excessive output current and power dissipation caused by faults or by bus contention are prevented by two mechanisms. A foldback current limit on the output stage provides immediate protection against short circuits over the whole common-mode voltage range. In addition, a thermal shutdown circuit forces the driver outputs into a high-impedance
state if the temperature rises excessively. There are two 2-pole screw terminals on board (+, B, A, -) for connecting RS422/485 bus twisted pair cable, along with the GND and VCC. The terminal inputs labeled as “A” and “B” are used to connect the bus wires. GND and VCC rails can be used to provide the power supply for another node. Note that the VCC terminal is directly routed to the 5V rail of the mikroBUS™. 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, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
Nucleo 32 with STM32F031K6 MCU board provides an affordable and flexible platform for experimenting with STM32 microcontrollers in 32-pin packages. Featuring Arduino™ Nano connectivity, it allows easy expansion with specialized shields, while being mbed-enabled for seamless integration with online resources. The
board includes an on-board ST-LINK/V2-1 debugger/programmer, supporting USB reenumeration with three interfaces: Virtual Com port, mass storage, and debug port. It offers a flexible power supply through either USB VBUS or an external source. Additionally, it includes three LEDs (LD1 for USB communication, LD2 for power,
and LD3 as a user LED) and a reset push button. The STM32 Nucleo-32 board is supported by various Integrated Development Environments (IDEs) such as IAR™, Keil®, and GCC-based IDEs like AC6 SW4STM32, making it a versatile tool for developers.
Microcontroller Overview
MCU Card / MCU
Architecture
ARM Cortex-M0
MCU Memory (KB)
32
Silicon Vendor
STMicroelectronics
Pin count
32
RAM (Bytes)
4096
You complete me!
Accessories
Click Shield for Nucleo-32 is the perfect way to expand your development board's functionalities with STM32 Nucleo-32 pinout. The Click Shield for Nucleo-32 provides two mikroBUS™ sockets to add any functionality from our ever-growing range of Click boards™. We are fully stocked with everything, from sensors and WiFi transceivers to motor control and audio amplifiers. The Click Shield for Nucleo-32 is compatible with the STM32 Nucleo-32 board, providing an affordable and flexible way for users to try out new ideas and quickly create prototypes with any STM32 microcontrollers, choosing from the various combinations of performance, power consumption, and features. The STM32 Nucleo-32 boards do not require any separate probe as they integrate the ST-LINK/V2-1 debugger/programmer and come with the STM32 comprehensive software HAL library and various packaged software examples. This development platform provides users with an effortless and common way to combine the STM32 Nucleo-32 footprint compatible board with their favorite Click boards™ in their upcoming projects.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
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 5 Click driver.
Key functions:
rs4855_generic_write
- Generic write function.rs4855_set_de_state
- Sets DE pin to high or low state.rs4855_set_re_state
- Sets RE pin to high or low state.
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 Rs4855 Click example
*
* # Description
* This example reads and processes data from RS485 5 clicks.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and enables the selected mode.
*
* ## Application Task
* Depending on the selected mode, it reads all the received data or sends the desired message
* every 2 seconds.
*
* ## Additional Function
* - rs4855_process ( ) - The general process of collecting the received data.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "rs4855.h"
#include "string.h"
#define PROCESS_RX_BUFFER_SIZE 500
#define TEXT_TO_SEND "MikroE\r\n"
// ------------------------------------------------------------------ VARIABLES
#define DEMO_APP_RECEIVER
// #define DEMO_APP_TRANSMITTER
static rs4855_t rs4855;
static log_t logger;
// ------------------------------------------------------- ADDITIONAL FUNCTIONS
static void rs4855_process ( void )
{
int32_t rsp_size;
char uart_rx_buffer[ PROCESS_RX_BUFFER_SIZE ] = { 0 };
uint8_t check_buf_cnt;
rsp_size = rs4855_generic_read( &rs4855, uart_rx_buffer, PROCESS_RX_BUFFER_SIZE );
if ( rsp_size >= strlen( TEXT_TO_SEND ) )
{
log_printf( &logger, "Received data: " );
for ( check_buf_cnt = 0; check_buf_cnt < rsp_size; check_buf_cnt++ )
{
log_printf( &logger, "%c", uart_rx_buffer[ check_buf_cnt ] );
}
}
Delay_ms ( 100 );
}
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
rs4855_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.
rs4855_cfg_setup( &cfg );
RS4855_MAP_MIKROBUS( cfg, MIKROBUS_1 );
rs4855_init( &rs4855, &cfg );
Delay_ms ( 100 );
#ifdef DEMO_APP_RECEIVER
rs4855_set_re_state( &rs4855, RS4855_PIN_STATE_LOW );
rs4855_set_de_state( &rs4855, RS4855_PIN_STATE_LOW );
log_info( &logger, "---- Receiver mode ----" );
#endif
#ifdef DEMO_APP_TRANSMITTER
rs4855_set_re_state( &rs4855, RS4855_PIN_STATE_HIGH );
rs4855_set_de_state( &rs4855, RS4855_PIN_STATE_HIGH );
log_info( &logger, "---- Transmitter mode ----" );
#endif
}
void application_task ( void )
{
#ifdef DEMO_APP_RECEIVER
rs4855_process( );
#endif
#ifdef DEMO_APP_TRANSMITTER
rs4855_generic_write( &rs4855, TEXT_TO_SEND, 8 );
log_info( &logger, "---- Data sent ----" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#endif
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
/*!
* \file
* \brief Rs4855 Click example
*
* # Description
* This example reads and processes data from RS485 5 clicks.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and enables the selected mode.
*
* ## Application Task
* Depending on the selected mode, it reads all the received data or sends the desired message
* every 2 seconds.
*
* ## Additional Function
* - rs4855_process ( ) - The general process of collecting the received data.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "rs4855.h"
#include "string.h"
#define PROCESS_RX_BUFFER_SIZE 500
#define TEXT_TO_SEND "MikroE\r\n"
// ------------------------------------------------------------------ VARIABLES
#define DEMO_APP_RECEIVER
// #define DEMO_APP_TRANSMITTER
static rs4855_t rs4855;
static log_t logger;
// ------------------------------------------------------- ADDITIONAL FUNCTIONS
static void rs4855_process ( void )
{
int32_t rsp_size;
char uart_rx_buffer[ PROCESS_RX_BUFFER_SIZE ] = { 0 };
uint8_t check_buf_cnt;
rsp_size = rs4855_generic_read( &rs4855, uart_rx_buffer, PROCESS_RX_BUFFER_SIZE );
if ( rsp_size >= strlen( TEXT_TO_SEND ) )
{
log_printf( &logger, "Received data: " );
for ( check_buf_cnt = 0; check_buf_cnt < rsp_size; check_buf_cnt++ )
{
log_printf( &logger, "%c", uart_rx_buffer[ check_buf_cnt ] );
}
}
Delay_ms ( 100 );
}
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
rs4855_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.
rs4855_cfg_setup( &cfg );
RS4855_MAP_MIKROBUS( cfg, MIKROBUS_1 );
rs4855_init( &rs4855, &cfg );
Delay_ms ( 100 );
#ifdef DEMO_APP_RECEIVER
rs4855_set_re_state( &rs4855, RS4855_PIN_STATE_LOW );
rs4855_set_de_state( &rs4855, RS4855_PIN_STATE_LOW );
log_info( &logger, "---- Receiver mode ----" );
#endif
#ifdef DEMO_APP_TRANSMITTER
rs4855_set_re_state( &rs4855, RS4855_PIN_STATE_HIGH );
rs4855_set_de_state( &rs4855, RS4855_PIN_STATE_HIGH );
log_info( &logger, "---- Transmitter mode ----" );
#endif
}
void application_task ( void )
{
#ifdef DEMO_APP_RECEIVER
rs4855_process( );
#endif
#ifdef DEMO_APP_TRANSMITTER
rs4855_generic_write( &rs4855, TEXT_TO_SEND, 8 );
log_info( &logger, "---- Data sent ----" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#endif
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
/*!
* \file
* \brief Rs4855 Click example
*
* # Description
* This example reads and processes data from RS485 5 clicks.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and enables the selected mode.
*
* ## Application Task
* Depending on the selected mode, it reads all the received data or sends the desired message
* every 2 seconds.
*
* ## Additional Function
* - rs4855_process ( ) - The general process of collecting the received data.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "rs4855.h"
#include "string.h"
#define PROCESS_RX_BUFFER_SIZE 500
#define TEXT_TO_SEND "MikroE\r\n"
// ------------------------------------------------------------------ VARIABLES
#define DEMO_APP_RECEIVER
// #define DEMO_APP_TRANSMITTER
static rs4855_t rs4855;
static log_t logger;
// ------------------------------------------------------- ADDITIONAL FUNCTIONS
static void rs4855_process ( void )
{
int32_t rsp_size;
char uart_rx_buffer[ PROCESS_RX_BUFFER_SIZE ] = { 0 };
uint8_t check_buf_cnt;
rsp_size = rs4855_generic_read( &rs4855, uart_rx_buffer, PROCESS_RX_BUFFER_SIZE );
if ( rsp_size >= strlen( TEXT_TO_SEND ) )
{
log_printf( &logger, "Received data: " );
for ( check_buf_cnt = 0; check_buf_cnt < rsp_size; check_buf_cnt++ )
{
log_printf( &logger, "%c", uart_rx_buffer[ check_buf_cnt ] );
}
}
Delay_ms ( 100 );
}
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
rs4855_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.
rs4855_cfg_setup( &cfg );
RS4855_MAP_MIKROBUS( cfg, MIKROBUS_1 );
rs4855_init( &rs4855, &cfg );
Delay_ms ( 100 );
#ifdef DEMO_APP_RECEIVER
rs4855_set_re_state( &rs4855, RS4855_PIN_STATE_LOW );
rs4855_set_de_state( &rs4855, RS4855_PIN_STATE_LOW );
log_info( &logger, "---- Receiver mode ----" );
#endif
#ifdef DEMO_APP_TRANSMITTER
rs4855_set_re_state( &rs4855, RS4855_PIN_STATE_HIGH );
rs4855_set_de_state( &rs4855, RS4855_PIN_STATE_HIGH );
log_info( &logger, "---- Transmitter mode ----" );
#endif
}
void application_task ( void )
{
#ifdef DEMO_APP_RECEIVER
rs4855_process( );
#endif
#ifdef DEMO_APP_TRANSMITTER
rs4855_generic_write( &rs4855, TEXT_TO_SEND, 8 );
log_info( &logger, "---- Data sent ----" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
#endif
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END