brushless18  2.1.0.0
Main Page

Brushless 18 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : Aug 2024.
  • Type : PWM type

Software Support

We provide a library for the Brushless 18 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 18 Click driver.

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of the Brushless 18 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 calibrates the click board.

void application_init ( void )
{
log_cfg_t log_cfg;
brushless18_cfg_t brushless18_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
brushless18_cfg_setup( &brushless18_cfg );
BRUSHLESS18_MAP_MIKROBUS( brushless18_cfg, MIKROBUS_1 );
if ( PWM_ERROR == brushless18_init( &brushless18, &brushless18_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( BRUSHLESS18_ERROR == brushless18_throttle_calib ( &brushless18 ) )
{
log_error( &logger, " Throttle calibration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

Changes the motor speed every 500 milliseconds with steps of 5%. At the minimal speed, the motor switches direction.

Each step will be logged on the USB UART where you can track the program flow.

void application_task ( void )
{
static uint8_t direction = BRUSHLESS18_DIRECTION_CW;
static int8_t speed = BRUSHLESS18_SPEED_MIN;
static int8_t speed_step = 5;
brushless18_drive_motor ( &brushless18, direction, speed );
log_printf( &logger, " Direction: %s\r\n",
( char * ) ( BRUSHLESS18_DIRECTION_CW == direction ? "CW" : "CCW" ) );
log_printf( &logger, " Speed: %u%%\r\n\n", ( uint16_t ) speed );
Delay_ms ( 500 );
speed += speed_step;
if ( speed > BRUSHLESS18_SPEED_MAX )
{
speed_step = -speed_step;
speed += speed_step;
speed += speed_step;
}
else if ( speed < BRUSHLESS18_SPEED_MIN )
{
speed_step = -speed_step;
speed += speed_step;
direction ^= 1;
Delay_ms ( 1000 );
}
}

Note

The theoretical maximal PWM Clock frequency for this click board is 500 Hz.

The default PWM Clock frequency is set to 400 Hz. To achieve such a low frequency, the user will probably need to decrease the MCU's main clock frequency in the Setup MCU Settings.

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.Brushless18

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.


brushless18_cfg_t
Brushless 18 Click configuration object.
Definition: brushless18.h:136
BRUSHLESS18_SPEED_MAX
#define BRUSHLESS18_SPEED_MAX
Definition: brushless18.h:91
brushless18_drive_motor
err_t brushless18_drive_motor(brushless18_t *ctx, uint8_t direction, uint8_t speed)
Brushless 18 drive motor module.
application_task
void application_task(void)
Definition: main.c:72
brushless18_throttle_calib
err_t brushless18_throttle_calib(brushless18_t *ctx)
Brushless 18 throttle calib module.
brushless18_cfg_setup
void brushless18_cfg_setup(brushless18_cfg_t *cfg)
Brushless 18 configuration object setup function.
brushless18_t
Brushless 18 Click context object.
Definition: brushless18.h:122
brushless18_init
err_t brushless18_init(brushless18_t *ctx, brushless18_cfg_t *cfg)
Brushless 18 initialization function.
BRUSHLESS18_MAP_MIKROBUS
#define BRUSHLESS18_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: brushless18.h:111
BRUSHLESS18_SPEED_MIN
#define BRUSHLESS18_SPEED_MIN
Brushless 18 speed and direction settings.
Definition: brushless18.h:90
application_init
void application_init(void)
Definition: main.c:36
BRUSHLESS18_DIRECTION_CW
#define BRUSHLESS18_DIRECTION_CW
Definition: brushless18.h:92
BRUSHLESS18_ERROR
@ BRUSHLESS18_ERROR
Definition: brushless18.h:152