brushless20  2.1.0.0
Main Page

Brushless 20 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : Jul 2022.
  • Type : I2C type

Software Support

We provide a library for the Brushless 20 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for Brushless 20 Click driver.

Standard key functions :

Example key functions :

  • brushless20_perform_com_sequence This function performs a single commutation sequence for the selected rotation direction at a desired speed.
    err_t brushless20_perform_com_sequence ( brushless20_t *ctx, uint8_t dir, uint8_t speed );
  • brushless20_drive_motor This function drives the motor for a desired time by performing multiple commutation sequences for the selected rotation direction at a desired speed.
    err_t brushless20_drive_motor ( brushless20_t *ctx, uint8_t dir, uint8_t speed, uint32_t time_ms );
  • brushless20_get_fault_pin This function returns the fault pin logic state.

Example Description

This example demonstrates the use of the Brushless 20 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.

void application_init ( void )
{
log_cfg_t log_cfg;
brushless20_cfg_t brushless20_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
brushless20_cfg_setup( &brushless20_cfg );
BRUSHLESS20_MAP_MIKROBUS( brushless20_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == brushless20_init( &brushless20, &brushless20_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( BRUSHLESS20_ERROR == brushless20_default_cfg ( &brushless20 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Drives the motor in both directions and changes the motor speed every 3 seconds approximately. The current driving direction and speed will be displayed on the USB UART.

void application_task ( void )
{
log_printf ( &logger, "\r\n Driving motor clockwise \r\n" );
for ( uint8_t speed = BRUSHLESS20_SPEED_MIN; speed <= BRUSHLESS20_SPEED_MAX; speed += 20 )
{
log_printf ( &logger, " Speed: %u\r\n", ( uint16_t ) speed );
if ( BRUSHLESS20_OK != brushless20_drive_motor ( &brushless20, BRUSHLESS20_DIR_CW, speed, 3000 ) )
{
log_error ( &logger, " Drive motor " );
}
}
Delay_ms ( 1000 );
log_printf ( &logger, "\r\n Driving motor counter-clockwise \r\n" );
for ( uint8_t speed = BRUSHLESS20_SPEED_MIN; speed <= BRUSHLESS20_SPEED_MAX; speed += 20 )
{
log_printf ( &logger, " Speed: %u\r\n", ( uint16_t ) speed );
if ( BRUSHLESS20_OK != brushless20_drive_motor ( &brushless20, BRUSHLESS20_DIR_CCW, speed, 3000 ) )
{
log_error ( &logger, " Drive motor " );
}
}
Delay_ms ( 1000 );
}

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Brushless20

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


brushless20_drive_motor
err_t brushless20_drive_motor(brushless20_t *ctx, uint8_t dir, uint8_t speed, uint32_t time_ms)
Brushless 20 drive motor function.
brushless20_default_cfg
err_t brushless20_default_cfg(brushless20_t *ctx)
Brushless 20 default configuration function.
brushless20_get_fault_pin
err_t brushless20_get_fault_pin(brushless20_t *ctx)
Brushless 20 get fault pin function.
brushless20_cfg_t
Brushless 20 Click configuration object.
Definition: brushless20.h:207
brushless20_perform_com_sequence
err_t brushless20_perform_com_sequence(brushless20_t *ctx, uint8_t dir, uint8_t speed)
Brushless 20 perform com sequence function.
brushless20_cfg_setup
void brushless20_cfg_setup(brushless20_cfg_t *cfg)
Brushless 20 configuration object setup function.
application_task
void application_task(void)
Definition: main.c:65
BRUSHLESS20_OK
@ BRUSHLESS20_OK
Definition: brushless20.h:226
brushless20_t
Brushless 20 Click context object.
Definition: brushless20.h:186
BRUSHLESS20_ERROR
@ BRUSHLESS20_ERROR
Definition: brushless20.h:227
BRUSHLESS20_DIR_CW
#define BRUSHLESS20_DIR_CW
Brushless 20 direction setting.
Definition: brushless20.h:101
BRUSHLESS20_DIR_CCW
#define BRUSHLESS20_DIR_CCW
Definition: brushless20.h:102
brushless20_init
err_t brushless20_init(brushless20_t *ctx, brushless20_cfg_t *cfg)
Brushless 20 initialization function.
application_init
void application_init(void)
Definition: main.c:29
BRUSHLESS20_MAP_MIKROBUS
#define BRUSHLESS20_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: brushless20.h:171
BRUSHLESS20_SPEED_MIN
#define BRUSHLESS20_SPEED_MIN
Brushless 20 driving speed and time settings.
Definition: brushless20.h:128
BRUSHLESS20_SPEED_MAX
#define BRUSHLESS20_SPEED_MAX
Definition: brushless20.h:129