Intermediate
30 min

Integrate sensorless BLDC motor driver into your designs easily with AMT49400 and STM32F107VCT6

Say goodbye to tangled wires

Brushless 21 Click with EasyMx PRO v7a for STM32

Published Apr 23, 2023

Click board™

Brushless 21 Click

Dev Board

EasyMx PRO v7a for STM32

Compiler

NECTO Studio

MCU

STM32F107VCT6

The perfect choice for enhancing the performance of home appliances such as fans and pumps, offering flexibility and versatility to optimize their operation

A

A

Hardware Overview

How does it work?

Brushless 21 Click is based on the AMT49400, a three-phase BLDC controller with integrated MOSFETs from Allegro Microsystems. The integrated field-oriented control (FOC) algorithm achieves the best efficiency and dynamic response and minimizes acoustic noise. Also, Allegro's proprietary non-reverse startup algorithm improves startup performance. The BLDC motor, connected to the terminals labeled U, V, and W, will start towards the target direction after power-up without reverse shaking or vibration. The Soft-On Soft-Off (SOSO) feature gradually increases the current to the motor at the ON command (windmill condition). It gradually reduces the current from the motor at the OFF command, further reducing the acoustic noise and operating the motor smoothly. This Click board™ allows interface selection to communicate with MCU. The selection between PWM and I2C interface can be

made by positioning SMD jumpers labeled as COMM SEL in an appropriate position. Note that all the jumpers' positions must be on the same side, or the Click board™ may become unresponsive. While the I2C interface is selected, setting motor-rated voltage, rated current, rated speed, resistance, and startup profiles are allowed via the EEPROM programmability. On the other side, the motor speed is controlled by applying a duty cycle command to the PWM input pin of the AMT49400. Alongside the PWM pin from the mikroBUS™ socket, this Click board™ also has the Enable pin labeled as EN and routed to the CS pin of the mikroBUS™ socket to optimize power consumption used for power ON/OFF purposes. The FG pin routed on the default INT pin of the mikroBUS™ socket provides motor speed information to the system, such as motor lock detection.

This feature monitors the motor position to determine if the motor is running as expected. If a lock condition is detected, the motor drive will be disabled for 5 seconds before an attempted auto-restart. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VIO SEL jumper. It allows both 3.3V and 5V capable MCUs to use the communication lines properly. Additionally, there is a possibility for the AMT49400 power supply selection via jumper labeled as VBB SEL to supply the AMT49400 from an external power supply terminal in the range from 4V to 16V or with 5V from mikroBUS™ power rail. However, the 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.

brushless-21-click-hardware-overview

Features overview

Development board

EasyMx PRO v7a for STM32 is the seventh generation of ARM development boards specially designed to develop embedded applications rapidly. It supports a wide range of 32-bit ARM microcontrollers from STMicroelectronics and a broad set of unique functions, such as the first-ever embedded debugger/programmer over USB-C. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. With two different connectors for each port, EasyMx PRO v7afor STM32 allows you to connect accessory boards, sensors, and custom electronics more efficiently than ever. Each part of the EasyMx

PRO v7a for STM32 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-23V AC or 9-32V DC via DC connector/screw terminals, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART, USB-HOST/DEVICE, CAN, and

Ethernet are also included, including the well-established mikroBUS™ standard, one display option for the TFT board line of products, and a standard TQFP socket for the seventh-generation MCU cards. This socket covers 32-bit ARM MCUs like STM32 Cortex-M3, -M7, and -M4 MCUs. EasyMx PRO v7afor STM32 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

EasyMx PRO v7a for STM32 double side image

Microcontroller Overview

MCU Card / MCU

default

Type

7th Generation

Architecture

ARM Cortex-M3

MCU Memory (KB)

10

Silicon Vendor

STMicroelectronics

Pin count

100

RAM (Bytes)

100

You complete me!

Accessories

2207V-2500kV BLDC Motor is an outrunner brushless DC motor with a kV rating of 2500 and an M5 shaft diameter. It is an excellent solution for fulfilling many functions initially performed by brushed DC motors or in RC drones, racing cars, and much more.

Brushless 21 Click accessories image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Enable
PC2
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
PWM Signal
PA0
PWM
Motor Speed Detection
PD10
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB6
SCL
I2C Data
PB7
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

Brushless 21 Click Schematic schematic

Step by step

Project assembly

EasyMx PRO v7a for STM32 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyMx PRO v7a for STM32 as your development board.

EasyMx PRO v7a for STM32 front image hardware assembly
GNSS2 Click front image hardware assembly
EasyMx PRO? v7 for STM32 MCUcard with STM32F407VGT6 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
EasyMx PRO v7a for STM32 Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
EasyMx PRO v7a for STM32 MCU Selection Necto Step hardware assembly
EasyPIC PRO v7a Display Selection Necto Step hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output via UART Mode

1. Once the code example is loaded, pressing the "FLASH" button initiates the build process, and programs it on the created setup.

2. After the programming is completed, click on the Tools icon in the upper-right panel, and select the UART Terminal.

3. After opening the UART Terminal tab, first check the baud rate setting in the Options menu (default is 115200). If this parameter is correct, activate the terminal by clicking the "CONNECT" button.

4. Now terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART_Application_Output

Software Support

Library Description

This library contains API for Brushless 21 Click driver.

Key functions:

  • brushless21_set_duty_cycle This function sets the duty cycle in percentages ( Range[ 0..1 ] ).

  • brushless21_get_motor_speed This function reads the motor speed in Hz.

  • brushless21_switch_direction This function switches the motor direction by toggling the DIR bit.

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 Brushless21 Click example
 *
 * # Description
 * This example demonstrates the use of the Brushless 21 click board by driving the 
 * motor at different speeds.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration which sets the GPIO 
 * as a default communication and enables the PWM.
 *
 * ## Application Task
 * Controls the motor speed by changing the PWM duty cycle once per second. The duty cycle ranges from 0% to 100%. 
 * When the click board is configured in I2C mode the motor switches the direction at a minimal speed.
 * Also, the chip internal temperature, VBB voltage and the motor speed readings are supported in I2C mode.
 * Each step will be logged on the USB UART where you can track the program flow.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "brushless21.h"

static brushless21_t brushless21;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    brushless21_cfg_t brushless21_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.
    brushless21_cfg_setup( &brushless21_cfg );
    BRUSHLESS21_MAP_MIKROBUS( brushless21_cfg, MIKROBUS_1 );
    err_t init_flag = brushless21_init( &brushless21, &brushless21_cfg );
    if ( ( PWM_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( BRUSHLESS21_ERROR == brushless21_default_cfg ( &brushless21 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    static int8_t duty_cnt = 1;
    static int8_t duty_inc = 1;
    float duty = duty_cnt / 10.0;
    
    if ( BRUSHLESS21_OK == brushless21_set_duty_cycle ( &brushless21, duty ) )
    {
        log_printf( &logger, "\r\n Duty Cycle : %d%%\r\n", ( uint16_t )( duty_cnt * 10 ) );
    }
    
    if ( BRUSHLESS21_DRV_SEL_I2C == brushless21.drv_sel ) 
    {
        int8_t temperature = 0;
        float motor_speed = 0;
        float vbb_voltage = 0;
        if ( BRUSHLESS21_OK == brushless21_get_temperature ( &brushless21, &temperature ) )
        {
            log_printf( &logger, " Temperature: %d C\r\n", ( int16_t ) temperature );
        }
        if ( BRUSHLESS21_OK == brushless21_get_motor_speed ( &brushless21, &motor_speed ) )
        {
            log_printf( &logger, " Motor Speed: %.2f Hz\r\n", motor_speed );
        }
        if ( BRUSHLESS21_OK == brushless21_get_vbb_voltage ( &brushless21, &vbb_voltage ) )
        {
            log_printf( &logger, " VBB Voltage: %.2f V\r\n", vbb_voltage );
        }
        if ( 0 == duty_cnt ) 
        {
            duty_inc = 1;
            if ( BRUSHLESS21_OK == brushless21_switch_direction ( &brushless21 ) )
            {
                log_printf( &logger, " Switch direction\r\n" );
            }
        }
    }
    
    if ( 10 == duty_cnt ) 
    {
        duty_inc = -1;
    }
    else if ( 0 == duty_cnt ) 
    {
        duty_inc = 1;
    }
    duty_cnt += duty_inc;
    Delay_ms( 1000 );
}

void main ( void )  
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.