brushless7 2.2.0
brushless7


Brushless 7 Click

Brushless 7 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : MikroE Team
  • Date : Jul 2020.
  • Type : I2C type

Software Support

Example Description

This example demonstrates the use of Brushless 7 Click board.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Brushless7

Example Key Functions

Application Init

Sets the default configuration and then configures the Click board for the selected mode.

void application_init ( void )
{
log_cfg_t log_cfg;
uint8_t error_flag = 0;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
BRUSHLESS7_MAP_MIKROBUS( cfg, MIKROBUS_1 );
brushless7_init( &brushless7, &cfg );
Delay_ms ( 100 );
brushless7_default_cfg( &brushless7 );
Delay_ms ( 100 );
{
error_flag |= brushless7_max_duty( &brushless7, 95.0 );
error_flag |= brushless7_start_duty( &brushless7, 5.0 );
error_flag |= brushless7_stop_duty( &brushless7, 2.0 );
log_printf( &logger, " ----- DUTY CONTROL ----- \r\n" );
}
{
error_flag |= brushless7_max_speed_rpm( &brushless7, BRUSHLESS7_MAX_SPEED_4096 );
log_printf( &logger, " ----- RPM CONTROL ----- \r\n" );
}
if ( BRUSHLESS7_DEV_ERROR == error_flag )
{
log_printf( &logger, " ----- ERROR ----- \r\n" );
for( ; ; );
}
}
#define BRUSHLESS7_CTRL_TYPE_RPM
Definition brushless7.h:158
#define BRUSHLESS7_CTRL_TYPE_DUTY
Definition brushless7.h:159
#define BRUSHLESS7_DEV_ERROR
Definition brushless7.h:140
#define BRUSHLESS7_MAP_MIKROBUS(cfg, mikrobus)
Definition brushless7.h:67
#define BRUSHLESS7_MAX_SPEED_4096
Definition brushless7.h:148
uint8_t brushless7_start_duty(brushless7_t *ctx, float duty_ptc)
Function for setting start duty of device.
uint8_t brushless7_max_duty(brushless7_t *ctx, float duty_ptc)
Function for setting max duty of device.
uint8_t brushless7_stop_duty(brushless7_t *ctx, float duty_ptc)
Function for setting stop duty of device.
void application_init(void)
Definition main.c:37
uint8_t demo_type_data
Definition main.c:33

Application Task

Increases and decreases the speed of the motor rotation by setting the duty cycle or rpm values depending on which mode is previously selected. It also switches the direction of rotation at the beginning of each cycle. All data is being logged on the USB UART where you can track their changes.

void application_task ( void )
{
Delay_ms ( 1000 );
Delay_ms ( 1000 );
{
log_printf( &logger, " The motor is accelerating...\r\n" );
log_printf( &logger, "------------------------------\r\n" );
brushless7_change_duty( &brushless7, 70.0 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, " The motor is slowing down...\r\n" );
log_printf( &logger, "------------------------------\r\n" );
brushless7_change_duty( &brushless7, 8.0 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
{
log_printf( &logger, " The motor is accelerating...\r\n" );
log_printf( &logger, "------------------------------\r\n" );
brushless7_start_rpm( &brushless7, 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &logger, " The motor is slowing down...\r\n" );
log_printf( &logger, "------------------------------\r\n" );
brushless7_start_rpm( &brushless7, 100 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
}
#define BRUSHLESS7_CTRL_TYPE_STOP
Definition brushless7.h:160
uint8_t brushless7_start_rpm(brushless7_t *ctx, uint16_t rpm_val)
Function for setting start rpm parameter of device.
void brushless7_toggle_dir_pin_state(brushless7_t *ctx)
Generic function for toggling DIR pin state.
void application_task(void)
Definition main.c:88

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

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.