DC Motor 12 click
DC Motor 12 Click is a compact add-on board with a brushed DC motor driver. This board features the TB9054FTG, a PWM-type, dual-channel, H-bridge, brushed DC motor driver from Toshiba Semiconductor. The TB9054FTG is rated for an operating voltage range from 4.5V to 28V, with the motor controlled directly through a PWM signal or SPI serial interface. In addition, this driver allows a dual configuration with two motors with 5A current ratings per channel or one 10A channel drive in a Parallel mode of operation. It also has complete diagnostic and protection capabilities supporting robust and reliable operation.
click Product page
Click library
- Author : Stefan Filipovic
- Date : Oct 2022.
- Type : SPI type
Software Support
We provide a library for the DC Motor 12 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 DC Motor 12 Click driver.
Standard key functions :
dcmotor12_cfg_setup
Config Object Initialization function.
void dcmotor12_cfg_setup(dcmotor12_cfg_t *cfg)
DC Motor 12 configuration object setup function.
DC Motor 12 Click configuration object.
Definition dcmotor12.h:298
dcmotor12_init
Initialization function.
err_t dcmotor12_init(dcmotor12_t *ctx, dcmotor12_cfg_t *cfg)
DC Motor 12 initialization function.
DC Motor 12 Click context object.
Definition dcmotor12.h:275
dcmotor12_default_cfg
Click Default Configuration function.
err_t dcmotor12_default_cfg(dcmotor12_t *ctx)
DC Motor 12 default configuration function.
Example key functions :
dcmotor12_get_motor_current
DC Motor 12 get motor current function.
err_t dcmotor12_get_motor_current(dcmotor12_t *ctx, float *current)
DC Motor 12 get motor current function.
dcmotor12_set_ch1_operation_mode
DC Motor 12 set ch1 operation mode function.
err_t dcmotor12_set_ch1_operation_mode(dcmotor12_t *ctx, uint8_t mode)
DC Motor 12 set ch1 operation mode function.
dcmotor12_set_cm_sel_pin
DC Motor 12 set cm sel pin function.
err_t dcmotor12_set_cm_sel_pin(dcmotor12_t *ctx, uint8_t state)
DC Motor 12 set cm sel pin function.
Example Description
This example demonstrates the use of DC Motor 12 click board by controlling the speed of DC motor over PWM duty cycle as well as displaying the motor current consumption.
The demo application is composed of two sections :
Application Init
Initializes the driver and performs the click default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ DCMOTOR12_OK
Definition dcmotor12.h:332
#define DCMOTOR12_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition dcmotor12.h:255
void application_init(void)
Definition main.c:35
Application Task
Changes the operation mode and motor speed by setting the PWM duty cycle and then calculates the motor current consumption for that speed. All data is being logged on the USB UART where you can track changes.
{
{
log_printf ( &logger, " MODE: OFF\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
{
{
float current;
log_printf ( &logger, " MODE: FORWARD\r\n" );
{
log_printf ( &logger, " Duty: %u\r\n", duty );
}
{
log_printf ( &logger, " Current: %.3f A\r\n\n", current );
}
Delay_ms ( 500 );
}
}
{
log_printf ( &logger, " MODE: BRAKE\r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
{
{
float current;
log_printf ( &logger, " MODE: REVERSE\r\n" );
{
log_printf ( &logger, " Duty: %u\r\n", duty );
}
{
log_printf ( &logger, " Current: %.3f A\r\n\n", current );
}
Delay_ms ( 500 );
}
}
}
#define DCMOTOR12_PIN_LOW_LEVEL
DC Motor 12 pin logic level setting.
Definition dcmotor12.h:200
#define DCMOTOR12_MODE_OUTPUT_OFF
DC Motor 12 channel operation mode settings.
Definition dcmotor12.h:191
#define DCMOTOR12_MODE_FORWARD
Definition dcmotor12.h:192
#define DCMOTOR12_MODE_BRAKE
Definition dcmotor12.h:194
#define DCMOTOR12_CONFIG56_DUTY_PERIOD_MAX
Definition dcmotor12.h:166
#define DCMOTOR12_MODE_REVERSE
Definition dcmotor12.h:193
#define DCMOTOR12_PIN_HIGH_LEVEL
Definition dcmotor12.h:201
err_t dcmotor12_set_ch1_duty_period(dcmotor12_t *ctx, uint16_t duty_period)
DC Motor 12 set ch1 duty period function.
void application_task(void)
Definition main.c:71
Note
The click board swiches should be set as follows: SW 1-2-3-4 : H-H-L-L This sets the click board as a SPI controlled single-channel device so the motor should be connected to OUT1/2 and OUT3/4.
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.DCMotor12
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.