Optimize motor control in electronic systems and unlock the flexibility to drive various motor types and other loads
A
A
Hardware Overview
How does it work?
H-Bridge 14 Click is based on the DRV8873, an automotive H-Bridge motor driver from Texas Instruments. It uses two logic inputs to control the H-Bridge driver, which consists of four N-channel MOSFETs. Those MOSFETs drive motors bi-directionally with up to 10A peak current. The motor has a configurable motor interface, a PH/EN or PWM, and an independent half-bridge control. The selection can be made over the software and the host MCU. The motor driver integrates current sensing and features proportional current output. It also features protections such as VM
under-voltage lockout, charge pump undervoltage, overcurrent protection, open load detection, thermal shutdown, fault conditions, and more. The power supply for the motor can be selected between the external and the 5V from the mikroBUS™ power rail. H-Bridge 14 Click uses a standard 4-wire SPI serial interface to communicate with the host MCU. Two control inputs are labeled IN1 and IN2. The onboard PCA9538 8-bit I/O port from NXP controls the sleep and bridge disable inputs. It also monitors the fault indication pin of the motor driver and
interrupts the host MCU over the INT pin. The I2C address of the PCA9538 can be set over the ADDR SEL jumper. This I/O port can be reset over the RST pin. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.
Features overview
Development board
Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand
functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,
which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.
Microcontroller Overview
MCU Card / MCU

Architecture
PIC32
MCU Memory (KB)
2048
Silicon Vendor
Microchip
Pin count
100
RAM (Bytes)
524288
You complete me!
Accessories
DC Gear Motor - 430RPM (3-6V) represents an all-in-one combination of a motor and gearbox, where the addition of gear leads to a reduction of motor speed while increasing the torque output. This gear motor has a spur gearbox, making it a highly reliable solution for applications with lower torque and speed requirements. The most critical parameters for gear motors are speed, torque, and efficiency, which are, in this case, 520RPM with no load and 430RPM at maximum efficiency, alongside a current of 60mA and a torque of 50g.cm. Rated for a 3-6V operational voltage range and clockwise/counterclockwise rotation direction, this motor represents an excellent solution for many functions initially performed by brushed DC motors in robotics, medical equipment, electric door locks, and much more.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for H-Bridge 14 Click driver.
Key functions:
hbridge14_set_pins
- H-Bridge 14 set pins function.hbridge14_sleep_state
- H-Bridge 14 control sleep function.hbridge14_drive_motor
- H-Bridge 14 drive motor function.
Open Source
Code example
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.
/*!
* @file main.c
* @brief H-Bridge 14 Click example
*
* # Description
* This example demonstrates the use of the H-Bridge 14 board by driving the
* motor in both directions with braking and coasting in between.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and performs the click default configuration.
*
* ## Application Task
* Drives the motor in both directions with coasting and braking in between, every sate is lasting 5 seconds.
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "hbridge14.h"
static hbridge14_t hbridge14;
static log_t logger;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
hbridge14_cfg_t hbridge14_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
hbridge14_cfg_setup( &hbridge14_cfg );
HBRIDGE14_MAP_MIKROBUS( hbridge14_cfg, MIKROBUS_1 );
err_t init_flag = hbridge14_init( &hbridge14, &hbridge14_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( HBRIDGE14_ERROR == hbridge14_default_cfg ( &hbridge14 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
uint8_t fault_status = 0;
hbridge14_drive_motor( &hbridge14, HBRIDGE14_DRIVE_MOTOR_CW );
log_printf( &logger, " Driving motor Clockwise \r\n" );
hbridge14_register_read( &hbridge14, HBRIDGE14_REG_FAULT_STATUS, &fault_status );
log_printf( &logger, " Fault status : 0x%.2X \r\n", ( uint16_t ) fault_status );
Delay_ms( 5000 );
hbridge14_drive_motor( &hbridge14, HBRIDGE14_DRIVE_MOTOR_BRAKE );
log_printf( &logger, " Brake is on \r\n" );
hbridge14_register_read( &hbridge14, HBRIDGE14_REG_FAULT_STATUS, &fault_status );
log_printf( &logger, " Fault status : 0x%.2X \r\n", ( uint16_t ) fault_status );
Delay_ms( 5000 );
hbridge14_drive_motor( &hbridge14, HBRIDGE14_DRIVE_MOTOR_CCW );
log_printf( &logger, " Driving motor counter-clockwise \r\n" );
hbridge14_register_read( &hbridge14, HBRIDGE14_REG_FAULT_STATUS, &fault_status );
log_printf( &logger, " Fault status : 0x%.2X \r\n", ( uint16_t ) fault_status );
Delay_ms( 5000 );
hbridge14_drive_motor( &hbridge14, HBRIDGE14_DRIVE_MOTOR_COASTING );
log_printf( &logger, " Driving motor Coasting \r\n" );
hbridge14_register_read( &hbridge14, HBRIDGE14_REG_FAULT_STATUS, &fault_status );
log_printf( &logger, " Fault status : 0x%.2X \r\n", ( uint16_t ) fault_status );
Delay_ms( 5000 );
}
int main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END