We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2021-08-06
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Brushed
Downloaded: 1566 times
Not followed.
License: MIT license
H-Bridge 6 Click is a compact add-on board that contains a DC motor driver for automotive applications. This board features the VNHD7008AY, an H-bridge motor driver for automotive DC motor driving from STMicroelectronics.
Do you want to subscribe in order to receive notifications regarding "H-Bridge 6 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "H-Bridge 6 click" changes.
Do you want to report abuse regarding "H-Bridge 6 click".
Library Description
The library covers all the necessary functions to control the H-Bridge 6 Click board™. A library performs communication with the device via the I2C interface. Using the PWM function, we can adjust the engine speed and direction.
Key functions:
void hbridge6_generic_write ( uint8_t reg, uint8_t tx_data )
- Generic write function.uint8_t hbridge6_generic_read ( uint8_t reg )
- Generic read function.void hbridge6_set_direction ( uint8_t direction )
- Set the direction function.Examples description
The application is composed of three sections :
void application_task ( )
{
mikrobus_logWrite( "-----------------------", _LOG_LINE );
mikrobus_logWrite( " Clockwise ", _LOG_LINE );
hbridge6_set_direction( HBRIDGE6_DIRECTION_CLOCKWISE );
pwm_duty_cycle = 100;
while ( pwm_duty_cycle < ( pwm_max_duty / 3 ) )
{
pwm_duty_cycle += 50;
mikrobus_logWrite( " >", _LOG_TEXT );
hbridge6_pwm_set_duty( pwm_duty_cycle );
Delay_ms( 100 );
}
mikrobus_logWrite( "", _LOG_LINE );
mikrobus_logWrite( "-----------------------", _LOG_LINE );
mikrobus_logWrite( " Brake ", _LOG_LINE );
hbridge6_set_direction( HBRIDGE6_DIRECTION_BRAKE );
Delay_ms( 3000 );
mikrobus_logWrite( "-----------------------", _LOG_LINE );
mikrobus_logWrite( " Counterclockwise ", _LOG_LINE );
hbridge6_set_direction( HBRIDGE6_DIRECTION_COUNTERCLOCKWISE );
pwm_duty_cycle = 100;
Delay_ms( 1000 );
while ( pwm_duty_cycle < ( pwm_max_duty / 3 ) )
{
pwm_duty_cycle += 50;
mikrobus_logWrite( " <", _LOG_TEXT );
hbridge6_pwm_set_duty( pwm_duty_cycle );
Delay_ms( 100 );
}
mikrobus_logWrite( "", _LOG_LINE );
mikrobus_logWrite( "-----------------------", _LOG_LINE );
mikrobus_logWrite( " Brake ", _LOG_LINE );
hbridge6_set_direction( HBRIDGE6_DIRECTION_BRAKE );
Delay_ms( 1000 );
hbridge6_pwm_stop( );
Delay_ms( 2000 );
hbridge6_pwm_start( );
Delay_ms( 1000 );
}
uint32_t hbridge6_pwm_init ( uint16_t freq )
- Initializes the Timer module in PWM mode.void hbridge6_pwm_set_duty ( uint16_t duty )
- The function changes PWM duty ratio.void hbridge6_pwm_start( )
- Starts appropriate PWM module.void hbridge6_pwm_stop( )
- Stops appropriate PWM module.Other mikroE Libraries used in the example:
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. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.