Revolutionize your connectivity strategy and cut expenses by leveraging your existing electrical infrastructure for seamless communication.
A
A
Hardware Overview
How does it work?
N-PLC Click is based on the SM2400, the ultimate Narrow-band Power Line Communication (N-PLC) modem from Semitech that combines cost-effective design optimized for PLC applications with a high level of programmability to address a multitude of communications schemes and evolving standards. The SM2400 system-on-chip (SoC) features a dual-core architecture for dedicated PHY signal processing and MAC layer functionality to guarantee superior communication performance while maintaining high flexibility and programmability for OFDM-based and other open standards and fully customized implementations. It has a set of firmware options implementing IEEE 1901.2 compliant PHY and MAC layers, a 6LoWPAN data link layer, PRIME, G3-PLC, and other special modes tailored for industrial IoT applications. The SM2400 combines the benefits of programmable architecture with power and efficiency by utilizing a DSP core configured specifically for N-PLC modulations and a dedicated 32-bit core that runs protocols. It contains a high-speed 256-bit AES-CCM engine to ensure standard compliance and secure communication, and all the necessary mixed-signal components, such as ADC, DAC, gain control and two OpAmp to deliver a cost-effective N-PLC system design for any application. In addition to the SM2400, this Click board™ also includes a PLC line driver, the SGM8423, a high efficiency, Class A/B, and a low distortion power line driver. It is optimized to accept a signal from a
Power Line Carrier modem, such as the SM2400, which is presented in the example code, where two such boards talk to each other in a transmitter/receiver configuration. Besides directly performing enable/shutdown control of the line driver, the SM2400 has one diagnostic signal that can indicate error conditions, such as overcurrent or overheating, reported by the line driver. In addition, it is also possible to supply high voltage (110/220VAC) as an input on the PLC CONN connector, which will be converted into a signal of the appropriate level via the N-PLC Wall Adapter, a simple yet very useful power line communication AC coupling circuit for safe and secure operation. The green PLC PWR LED signal that the N-PLC Wall Adapter is connected and powered. The SM2400 communicates with an MCU using the UART interface as its main one, with commonly used UART RX and TX pins and the optional hardware flow control pins UART CTS and RTS (Clear to Send and Ready to Send). The UART interface serves as the primary interface to a host, which can be an MCU or a converter, such as serial-to-USB. As an alternative to the UART interface, users also have at their disposal the lines of the SPI serial interface (to use this interface, it is necessary to populate the appropriate 0Ω resistors to activate the SPI lines). The SM2400 executes its firmware from internal memory, with the loaded code at a boot time. The SM2400 can boot either from an external SPI flash, the AT25FF041A, or from a host MCU via UART interface depending on
the logic state of the MD1 pin of the mikroBUS™ socket (0 - boot over UART interface that allows direct firmware download (boot from the host), 1 – boot from external SPI flash memory), with the host MCU being the Master. In addition, the SM2400 provides the possibility of a reset via the RST pin of the mikroBUS™ socket (asserting this pin causes full chip reset and reboot), as well as visual detection of the communication status via the red PHY LED, which is asserted when an incoming packet is detected. The power supply of this Click board™ is performed very simply, without any additional hardware configuration (depending on the power supply capability and the desired range). It is possible to power the board in two ways: internally and externally. By default, the board power will be provided internally over the LM5158 boost converter in the value of 15V, which is obtained from the 5V mikroBUS™ power rail. When applying an external power supply of 15VDC on the VEXT terminal, the N-PLC Click will automatically be powered from the external source thanks to the protection of the converter, which automatically recognizes the presence of the external power supply and gives it priority. This Click board™ can be operated only with a 3.3V 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-64 with STM32G071RB MCU offers a cost-effective and adaptable platform for developers to explore new ideas and prototype their designs. This board harnesses the versatility of the STM32 microcontroller, enabling users to select the optimal balance of performance and power consumption for their projects. It accommodates the STM32 microcontroller in the LQFP64 package and includes essential components such as a user LED, which doubles as an ARDUINO® signal, alongside user and reset push-buttons, and a 32.768kHz crystal oscillator for precise timing operations. Designed with expansion and flexibility in mind, the Nucleo-64 board features an ARDUINO® Uno V3 expansion connector and ST morpho extension pin
headers, granting complete access to the STM32's I/Os for comprehensive project integration. Power supply options are adaptable, supporting ST-LINK USB VBUS or external power sources, ensuring adaptability in various development environments. The board also has an on-board ST-LINK debugger/programmer with USB re-enumeration capability, simplifying the programming and debugging process. Moreover, the board is designed to simplify advanced development with its external SMPS for efficient Vcore logic supply, support for USB Device full speed or USB SNK/UFP full speed, and built-in cryptographic features, enhancing both the power efficiency and security of projects. Additional connectivity is
provided through dedicated connectors for external SMPS experimentation, a USB connector for the ST-LINK, and a MIPI® debug connector, expanding the possibilities for hardware interfacing and experimentation. Developers will find extensive support through comprehensive free software libraries and examples, courtesy of the STM32Cube MCU Package. This, combined with compatibility with a wide array of Integrated Development Environments (IDEs), including IAR Embedded Workbench®, MDK-ARM, and STM32CubeIDE, ensures a smooth and efficient development experience, allowing users to fully leverage the capabilities of the Nucleo-64 board in their projects.
Microcontroller Overview
MCU Card / MCU
Architecture
ARM Cortex-M0
MCU Memory (KB)
128
Silicon Vendor
STMicroelectronics
Pin count
64
RAM (Bytes)
36864
You complete me!
Accessories
Click Shield for Nucleo-64 comes equipped with two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the STM32 Nucleo-64 board with no effort. This way, Mikroe allows its users to add any functionality from our ever-growing range of Click boards™, such as WiFi, GSM, GPS, Bluetooth, ZigBee, environmental sensors, LEDs, speech recognition, motor control, movement sensors, and many more. More than 1537 Click boards™, which can be stacked and integrated, are at your disposal. The STM32 Nucleo-64 boards are based on the microcontrollers in 64-pin packages, a 32-bit MCU with an ARM Cortex M4 processor operating at 84MHz, 512Kb Flash, and 96KB SRAM, divided into two regions where the top section represents the ST-Link/V2 debugger and programmer while the bottom section of the board is an actual development board. These boards are controlled and powered conveniently through a USB connection to program and efficiently debug the Nucleo-64 board out of the box, with an additional USB cable connected to the USB mini port on the board. Most of the STM32 microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the STM32 Nucleo-64 board with our Click Shield for Nucleo-64, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.
An assortement of compatible AC plugs for all parts of the world are also sold. Reliability is paramount when it comes to power supply units. That's why we opted to carry Sunny Power Supply units. Note that power supply units are sold without AC plugs. Depending on where you are in the world, or where you plan to be, we also offer a wide selection of compatible AC plugs.
MIKROE offers a wide range of AC plugs for our Wall Power Supply units compatible with standards from Europe, the USA, the UK, India, China, Brazil, Australia, South Africa, Korea, and Argentina.
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 N-PLC Click driver.
Key functions:
nplc_set_mode
- This function sets operation mode to command or data.nplc_generic_write
- This function writes a desired number of data bytes by using UART serial interface.nplc_generic_read
- This function reads a desired number of data bytes by using UART serial interface.
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 main.c
* @brief N-PLC Click Example.
*
* # Description
* This example demonstrates the use of an N-PLC click boards by showing
* the communication between the two click boards configured as a receiver and transmitter.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver, resets the click board to default config, displays the firmware version
* and switches to data operation mode. After that displays the selected application mode
* and sends an initial message in case of transmitter mode.
*
* ## Application Task
* Reads all the received data and echoes them back to the transmitter. The received and echoed messages
* will be displayed on the USB UART.
*
* @note
* Once both devices are programmed, one as a receiver and the other as a transmitter, you will need to reset
* the transmitter board in order to start the communication by sending an initial message.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "nplc.h"
// Comment out the line below in order to switch the application mode to receiver
// #define DEMO_APP_TRANSMITTER
#define DEMO_TEXT_MESSAGE "MikroE - N-PLC click board"
#define PROCESS_BUFFER_SIZE 200
#define RSP_TIMEOUT_MS 20000
static nplc_t nplc;
static log_t logger;
static char app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
/**
* @brief N-PLC clearing application buffer.
* @details This function clears memory of application buffer and reset its length and counter.
* @note None.
*/
static void nplc_clear_app_buf ( void );
/**
* @brief N-PLC data reading function.
* @details This function reads data from device and concatenates data to application buffer.
* @return @li @c 0 - Read some data.
* @li @c -1 - Nothing is read or buffer overflow error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t nplc_process ( void );
/**
* @brief N-PLC display response function.
* @details This function checks if any data is received from device and displays it on the USB UART.
* @return @li @c 0 - Read some data.
* @li @c -1 - Timeout error.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t nplc_display_rsp ( void );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
nplc_cfg_t nplc_cfg; /**< Click config object. */
/**
* 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.
nplc_cfg_setup( &nplc_cfg );
NPLC_MAP_MIKROBUS( nplc_cfg, MIKROBUS_1 );
if ( UART_ERROR == nplc_init( &nplc, &nplc_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
nplc_process( );
nplc_clear_app_buf( );
log_printf( &logger, " - HW reset -\r\n" );
nplc_hw_reset ( &nplc );
nplc_display_rsp ( );
log_printf( &logger, " - Go to command mode -\r\n" );
nplc_set_mode ( &nplc, NPLC_MODE_COMMAND );
nplc_display_rsp ( );
log_printf( &logger, " - Factory reset -\r\n" );
nplc_factory_reset ( &nplc );
nplc_display_rsp ( );
log_printf( &logger, " - Reboot -\r\n" );
nplc_sw_reset ( &nplc );
nplc_display_rsp ( );
log_printf( &logger, " - Go to command mode -\r\n" );
nplc_set_mode ( &nplc, NPLC_MODE_COMMAND );
nplc_display_rsp ( );
log_printf( &logger, " - Show firmware version -\r\n" );
nplc_firmware_version ( &nplc );
nplc_display_rsp ( );
log_printf( &logger, " - Go to data mode -\r\n" );
nplc_set_mode ( &nplc, NPLC_MODE_DATA );
#ifdef DEMO_APP_TRANSMITTER
log_printf( &logger, " Application Mode: Transmitter\r\n" );
log_printf( &logger, " Sending initial message: %s", ( char * ) DEMO_TEXT_MESSAGE );
nplc_generic_write( &nplc, DEMO_TEXT_MESSAGE, strlen ( DEMO_TEXT_MESSAGE ) );
log_printf( &logger, "\r\n--------------------------------\r\n" );
Delay_ms( 1000 );
#else
log_printf( &logger, " Application Mode: Receiver\r\n" );
#endif
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
nplc_process ( );
if ( app_buf_len > 0 )
{
Delay_ms( 500 );
nplc_process( );
log_printf( &logger, " Received message: %s", app_buf );
log_printf( &logger, "\r\n--------------------------------\r\n" );
Delay_ms( 500 );
log_printf( &logger, " Sending echo response: %s", app_buf );
nplc_generic_write( &nplc, app_buf, app_buf_len );
log_printf( &logger, "\r\n--------------------------------\r\n\n" );
nplc_clear_app_buf( );
Delay_ms( 1000 );
}
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
static void nplc_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
static err_t nplc_process ( void )
{
int32_t rx_size;
char rx_buff[ PROCESS_BUFFER_SIZE ] = { 0 };
Delay_ms ( 1 );
rx_size = nplc_generic_read( &nplc, rx_buff, PROCESS_BUFFER_SIZE );
Delay_ms ( 1 );
if ( rx_size > 0 )
{
int32_t buf_cnt = 0;
if ( ( app_buf_len + rx_size ) > PROCESS_BUFFER_SIZE )
{
nplc_clear_app_buf( );
return NPLC_ERROR;
}
else
{
buf_cnt = app_buf_len;
app_buf_len += rx_size;
}
for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ )
{
if ( rx_buff[ rx_cnt ] )
{
app_buf[ ( buf_cnt + rx_cnt ) ] = rx_buff[ rx_cnt ];
}
else
{
app_buf_len--;
buf_cnt--;
}
}
return NPLC_OK;
}
return NPLC_ERROR;
}
static err_t nplc_display_rsp ( void )
{
uint32_t timeout = RSP_TIMEOUT_MS;
while ( timeout-- )
{
nplc_process( );
if ( app_buf_len > 0 )
{
Delay_ms( 100 );
nplc_process( );
for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
{
log_printf( &logger, "%c", app_buf[ buf_cnt ] );
}
nplc_clear_app_buf( );
log_printf( &logger, "\r\n--------------------------------\r\n" );
return NPLC_OK;
}
}
return NPLC_ERROR;
}
// ------------------------------------------------------------------------ END