Intermediate
30 min

Optimize brushless motor control with TC78B011FTG and STM32F415RG

Innovative and reliable

Brushless 23 Click with STM32 M4 clicker

Published May 04, 2023

Click board™

Brushless 23 Click

Dev. board

STM32 M4 clicker

Compiler

NECTO Studio

MCU

STM32F415RG

Upgrade your design with an advanced brushless motor driver for smoother, quieter, and more precise motor control

A

A

Hardware Overview

How does it work?

Brushless 23 Click is based on the TC78B011FTG, a three-phase sine-wave PWM pre-driver capable of driving Delta- or Wye-configured motors from Toshiba Semiconductor. Motor rotation is controlled without Hall sensors by detecting the rotational position from the induced voltage. The TC78B011FTG has a built-in closed-loop speed control function, which regulates and maintains the motor rotational speed under dynamic power fluctuations and load variations. This function has an internal non-volatile memory (NVM) for speed profile setting. The TC78B011FTG also has protection features such as thermal shutdown, under-voltage, over-current protection, lock detection, and more. The TC78B011FTG has a speed control command that controls the motor's start, stop, and rotation speed. This signal type is determined by the position of an onboard SW2 switch and register setting, allowing the selection among PWM, analog voltage signal, and standard I2C 2-Wire interface to read data and configure settings with a maximum frequency of 400kHz. The TC78B011FTG also allows choosing its I2C slave address by positioning SMD switches labeled SW3 and SW4 to an appropriate position. In the case of a PWM signal or analog voltage signal, the TC78B011FTG is controlled through the mikroBUS™ pin marked

as SPD. This Click board™ has several operational modes: Standby, Idle, Brake, and Error Mode. Standby mode is available to reduce the power consumption, controlled by the SBY pin of the mikroBUS™ socket, together with register settings. After Power-on, with the SBY pin disabled, the TC78B011FTG reads parameters from NVM and stores them in the registers. After that, IC goes to the Brake sequence and moves to Idle mode. The brake function is controllable by a register setting or an onboard SW1 switch. The TC78B011FTG starts the motor by Start-Up sequence with the speed control command set. When an abnormal condition is detected, IC moves to Error mode and automatically restarts after restart time. In Error mode with Stop as a speed control command, the TC78B011FTG will move to Idle mode. Alongside I2C communication, several signals connected to the mikroBUS™ socket pins are also used to forward the information to the MCU. The DIR pin of the mikroBUS™ socket is used to select the direction of motor rotation (clockwise/counterclockwise), while the CMO pin serves as the motor's output current monitoring. Also, the TC78B011FTG provides selectable interrupts chosen via the INT SEL jumper routed on the INT pin of the mikroBUS™ socket by positioning the SMD jumper

to an appropriate position marked as ALR od FG. The default position of this jumper is the FG position which serves as a rotation speed indicator, while the ALR position represents an abnormality detection feature. Both features have visual indicators; a red LED marked as ALR and a blue LED labeled as FG. Brushless 23 Click is realized using six N-channel MOSFETs, the SSM6K513NU also from Toshiba Semiconductor, two for each of the three phases. These FETs, capable of handling 15A, allow low power dissipation when driving 5A BLDC before hitting the output current limit threshold (used to restrain the current flowing to the motor). It also supports an external power supply for the motor, which can be connected to the input terminal labeled as VM and should be within the range of 11V to 27V, while the BLDC motor coils can be connected to the terminals labeled as U, V, and W. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. 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-23-click-hardware-overview

Features overview

Development board

STM32 M4 Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit ARM Cortex-M4 microcontroller, the STM32F415RG from STMicroelectronics, a USB connector, LED indicators, buttons, a JTAG connector, and a header for interfacing with external electronics. Thanks to its compact design with clear and easy-recognizable silkscreen markings, it provides a fluid and immersive working experience, allowing

access anywhere and under any circumstances. Each part of the STM32 M4 Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the STM32 M4 Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for the STM32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Mini-B connection can provide up to 500mA of current, which is more than enough to operate all

onboard and additional modules. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. STM32 M4 Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

STM32 M4 Clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

STMicroelectronics

Pin count

64

RAM (Bytes)

196608

You complete me!

Accessories

Brushless DC (BLDC) Motor with a Hall sensor represents a high-performance motor from the 42BLF motor series. This motor, wired in a star configuration, boasts a Hall Effect angle of 120°, ensuring precise and reliable performance. With a compact motor length of 47mm and a lightweight design tipping the scales at just 0.29kg, this BLDC motor is engineered to meet your needs. Operating flawlessly at a voltage rating of 24VDC and a speed range of 4000 ± 10% RPM, this motor offers consistent and dependable power. It excels in a normal operational temperature range from -20 to +50°C, maintaining efficiency with a rated current of 1.9A. Also, this product seamlessly integrates with all Brushless Click boards™ and those that require BLDC motors with Hall sensors.

Brushless 23 Click accessories image

Used MCU Pins

mikroBUS™ mapper

Current Monitor
PA0
AN
Rotation Direction
PB5
RST
Standby
PB12
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Speed Control
PB0
PWM
Interrupt
PB1
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB10
SCL
I2C Data
PB11
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Brushless 23 Click Schematic schematic

Step by step

Project assembly

STM32 M4 clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the STM32 M4 clicker as your development board.

STM32 M4 clicker front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
STM32 M4 Mini B Connector Access Clicker - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
STM32 M4 Clicker HA MCU/Select Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for Brushless 23 Click driver.

Key functions:

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

  • brushless23_switch_direction This function switches the direction by toggling the DIR pin state.

  • brushless23_get_motor_speed This function reads the motor speed in Hz.

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief Brushless23 Click example
 *
 * # Description
 * This example demonstrates the use of the Brushless 23 click board by driving the 
 * motor in both directions at different speeds.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 *
 * ## Application Task
 * Controls the motor speed by changing the PWM duty cycle every 2 seconds.
 * The duty cycle ranges from 20% to 80%. At the minimal speed, the motor switches direction.
 * 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 "brushless23.h"

static brushless23_t brushless23;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    brushless23_cfg_t brushless23_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.
    brushless23_cfg_setup( &brushless23_cfg );
    BRUSHLESS23_MAP_MIKROBUS( brushless23_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == brushless23_init( &brushless23, &brushless23_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( BRUSHLESS23_ERROR == brushless23_default_cfg ( &brushless23 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    static int8_t duty_cnt = 2;
    static int8_t duty_inc = 1;
    float duty = duty_cnt / 10.0;
    brushless23_pwm_set_duty_cycle ( &brushless23, duty );
    log_printf( &logger, "\r\n Duty cycle: %u%%\r\n", ( uint16_t )( duty_cnt * 10 ) );
    Delay_ms ( 1500 );
    float motor_speed_hz = 0;
    if ( BRUSHLESS23_OK == brushless23_get_motor_speed ( &brushless23, &motor_speed_hz ) )
    {
        log_printf( &logger, " Speed: %.1f Hz\r\n", motor_speed_hz );
    }
    duty_cnt += duty_inc;
    if ( duty_cnt > 8 ) 
    {
        duty_cnt = 7;
        duty_inc = -1;
    }
    else if ( duty_cnt < 2 ) 
    {
        duty_cnt = 2;
        duty_inc = 1;
        log_printf( &logger, "\r\n Switch direction\r\n" );
        brushless23_pwm_set_duty_cycle ( &brushless23, BRUSHLESS23_DUTY_CYCLE_MIN_PCT );
        Delay_ms ( 500 );
        brushless23_switch_direction ( &brushless23 );
    }
    Delay_ms ( 500 );
}

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.