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: 2019-07-22
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Brushed
Downloaded: 3526 times
Not followed.
License: MIT license
DC Motor 11 Click is a brushed DC motor driver with the current limiting and current sensing. It is based on the DRV8830, an integrated H-Bridge driver IC, optimized for motor driving applications.
Do you want to subscribe in order to receive notifications regarding "DC Motor 11 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "DC Motor 11 click" changes.
Do you want to report abuse regarding "DC Motor 11 click".
Library Description
The library contains all the necessary functions for full DC motor control.
Key functions:
void dcmotor11_control(uint8_t dir, uint8_t speed)
- Motor Control.void dcmotor11_stop()
- Motor Stop.uint8_t dcmotor11_getFault()
- Get Fault.Examples description
The application is composed of three sections :
void applicationTask()
{
uint8_t dataReady_;
char receivedData_;
dataReady_ = UART_Rdy_Ptr( );
if (dataReady_ != 0)
{
receivedData_ = UART_Rd_Ptr( );
switch (receivedData_)
{
case '+' :
{
/* Speed increase */
motorSpeed += 4;
if(motorSpeed >= _DCMOTOR11_VSET_4820mV)
{
mikrobus_logWrite("---- MAX SPEED ----", _LOG_LINE);
motorSpeed = _DCMOTOR11_VSET_4820mV;
dcmotor11_control(motorDir, motorSpeed);
}
else
{
mikrobus_logWrite("---- Speed increase ----", _LOG_TEXT);
mikrobus_logWrite(" MOTOR SPEED: ", _LOG_TEXT);
IntToStr(motorSpeed, demoText);
mikrobus_logWrite(demoText, _LOG_LINE);
dcmotor11_control(motorDir, motorSpeed);
}
break;
}
case '-' :
{
/* Speed decrease */
motorSpeed -= 4;
if( motorSpeed < _DCMOTOR11_VSET_480mV )
{
mikrobus_logWrite("---- MIN SPEED ----", _LOG_LINE);
motorSpeed = _DCMOTOR11_VSET_480mV;
}
else
{
mikrobus_logWrite("---- Speed decrease ----", _LOG_TEXT);
mikrobus_logWrite(" MOTOR SPEED: ", _LOG_TEXT);
IntToStr(motorSpeed, demoText);
mikrobus_logWrite(demoText, _LOG_LINE);
dcmotor11_control(motorDir, motorSpeed);
}
break;
}
case 's' :
{
/* Stop / Start */
if(fMotorState == 1)
{
mikrobus_logWrite("---- Stop Motor!!! ----", _LOG_LINE);
fMotorState = 0;
dcmotor11_stop();
}
else
{
mikrobus_logWrite("---- Start Motor ----", _LOG_LINE);
fMotorState = 1;
motorSpeed = _DCMOTOR11_VSET_480mV;
dcmotor11_control(motorDir, motorSpeed);
}
break;
}
case 'd' :
{
/* Direction - Forward / Backword */
if(motorDir == 2)
{
mikrobus_logWrite("---- Direction - [FORWARD] ----", _LOG_LINE);
motorDir = 1;
dcmotor11_control(motorDir, motorSpeed);
}
else
{
mikrobus_logWrite("---- Direction - [BACKWARD] ----", _LOG_LINE);
motorDir = 2;
dcmotor11_control(motorDir, motorSpeed);
}
break;
}
}
}
}
The full application code, and ready to use projects can be found on our LibStock page.
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.