dcmotor21  2.0.0.0
Main Page

DC Motor 21 click

DC Motor 21 Click is a compact add-on board that contains a brushed DC motor driver. This board features the A3910, a DC motor driver designed for low voltage power applications from Allegro Microsystems. It is controlled via several GPIO pins and has a wide operating voltage range with an output current capacity of 500mA. In addition to the possibility to be used in the full-bridge configuration to drive a single bidirectional DC motor, it can also be used as a dual half-bridge to drive dual DC motors.

click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Sep 2021.
  • Type : GPIO type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of DC Motor 21 click board.

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;
dcmotor21_cfg_t dcmotor21_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
dcmotor21_cfg_setup( &dcmotor21_cfg );
DCMOTOR21_MAP_MIKROBUS( dcmotor21_cfg, MIKROBUS_1 );
if ( DIGITAL_OUT_UNSUPPORTED_PIN == dcmotor21_init( &dcmotor21, &dcmotor21_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
dcmotor21_default_cfg ( &dcmotor21 );
log_info( &logger, " Application Task " );
}

Application Task

In the span of six seconds, it drives the motor in one direction, then switches the direction, and after that disconnects the motor. Each step will be logged on the USB UART where you can track the program flow.

void application_task ( void )
{
log_printf( &logger, " \r\n Driving the motor...\r\n" );
Delay_ms( 2000 );
log_printf( &logger, " Switch direction.\r\n" );
Delay_ms( 2000 );
log_printf( &logger, " The motor is disconnected.\r\n" );
Delay_ms( 2000 );
}

Note

For this example, a DC motor should be connected to OUT1 and OUT2 lines.

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

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.


dcmotor21_set_out_1
void dcmotor21_set_out_1(dcmotor21_t *ctx, uint8_t state)
DC Motor 21 set out 1 function.
DCMOTOR21_OUT_LOW
#define DCMOTOR21_OUT_LOW
DC Motor 21 OUT setting.
Definition: dcmotor21.h:58
DCMOTOR21_MAP_MIKROBUS
#define DCMOTOR21_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: dcmotor21.h:78
dcmotor21_default_cfg
void dcmotor21_default_cfg(dcmotor21_t *ctx)
DC Motor 21 default configuration function.
application_task
void application_task(void)
Definition: main.c:64
dcmotor21_t
DC Motor 21 Click context object.
Definition: dcmotor21.h:92
dcmotor21_init
err_t dcmotor21_init(dcmotor21_t *ctx, dcmotor21_cfg_t *cfg)
DC Motor 21 initialization function.
DCMOTOR21_OUT_HIGH_Z
#define DCMOTOR21_OUT_HIGH_Z
Definition: dcmotor21.h:60
DCMOTOR21_OUT_HIGH
#define DCMOTOR21_OUT_HIGH
Definition: dcmotor21.h:59
application_init
void application_init(void)
Definition: main.c:32
dcmotor21_set_out_2
void dcmotor21_set_out_2(dcmotor21_t *ctx, uint8_t state)
DC Motor 21 set out 2 function.
dcmotor21_cfg_t
DC Motor 21 Click configuration object.
Definition: dcmotor21.h:105
dcmotor21_cfg_setup
void dcmotor21_cfg_setup(dcmotor21_cfg_t *cfg)
DC Motor 21 configuration object setup function.