拥抱刷式电机控制。使用这个直流电机控制解决方案来控制电机电流限制和电流感应!
A
A
硬件概览
它是如何工作的?
DC Motor 11 Click基于德州仪器的DRV8830,这是一款带有串行接口的低电压电机驱动器。该IC是一款集成的H桥驱动器,具有通过单个电阻限制负载电流的电流调节电路。H桥的低导通电阻降低了总功率损耗,而先进的控制电路在输出状态改变时注入死区间隔,防止电流穿越。DRV8830还集成了保护功能,包括欠压、过流和过温保护。这些事件中的每一个都将导致H桥的MOSFET被禁用。消除故障条件后,设备将继续其操作。DRV8830包括一个与DAC连接的内部参考电压。该DAC
产生一个用于设置PWM调节输出电压的电压,因此设置了电机的速度和方向。DAC由I2C接口的VSET位控制。有关所需输出电压的详细命令,请参阅DRV8830数据表。DC Motor 11 click使用I2C接口与主MCU通信,并且故障引脚(FLT)被路由到mikroBUS™插座的INT引脚。可以使用附加的SMD跳线帽(JP1和JP2)选择I2C地址,标记为ADDR SEL,确定了DRV8830从设备I2C地址的最低有效位。虽然DRV8830支持通过负载的最大直流/有效值或峰值驱动电流为1A,但限制为最
大0.6A。较高的电流将导致过流保护被激活。电机的峰值电流被限制在约1A,确保可靠的启动,同时防止过流保护被激活,即使施加了较大的负载扭矩。尽管H桥之间的电阻较低,但应监测电流以防止在负载相当高的情况下过度加热。该Click板只能使用3.3V逻辑电压电平操作。在使用具有不同逻辑电平的MCU之前,板子必须执行适当的逻辑电压电平转换。但是,该Click板配备了包含函数和示例代码的库,可用作进一步开发的参考。
功能概述
开发板
Fusion for TIVA v8 是一款专为快速开发嵌入式应用的需求而特别设计的开发板。它支持广泛的微控制器,如不同的32位ARM® Cortex®-M基础MCUs,来自Texas Instruments,无论它们的引脚数量如何,并且具有一系列独特功能,例如首次通过WiFi网络实现的嵌入式调试器/程序员。开发板布局合理,设计周到,使得最终用户可以在一个地方找到所有必要的元素,如开关、按钮、指示灯、连接器等。得益于创新的制造技术,Fusion for TIVA v8 提供了流畅而沉浸式的工作体验,允许在任何情况下、任何地方、任何
时候都能访问。Fusion for TIVA v8开发板的每个部分都包含了使同一板块运行最高效的必要组件。一个先进的集成CODEGRIP程序/调试模块提供许多有价值的编程/调试选项,包括对JTAG、SWD和SWO Trace(单线输出)的支持,并与Mikroe软件环境无缝集成。此外,它还包括一个干净且调节过的开发板电源供应模块。它可以使用广泛的外部电源,包括电池、外部12V电源供应和通过USB Type-C(USB-C)连接器的电源。通信选项如USB-UART、USB HOST/DEVICE、CAN(如果MCU卡支持的话)和以
太网也包括在内。此外,它还拥有广受好评的 mikroBUS™标准,为MCU卡提供了标准化插座(SiBRAIN标准),以及两种显示选项,用于TFT板线产品和基于字符的LCD。Fusion for TIVA v8 是Mikroe快速开发生态系统的一个组成部分。它由Mikroe软件工具原生支持,得益于大量不同的Click板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作和开发的许多方面。
微控制器概述
MCU卡片 / MCU
类型
8th Generation
建筑
ARM Cortex-M4
MCU 内存 (KB)
512
硅供应商
Texas Instruments
引脚数
212
RAM (字节)
262144
你完善了我!
配件
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
原理图
一步一步来
项目组装
实时跟踪您的结果
应用输出通过UART模式
1. 一旦代码示例加载完成,按下 "FLASH" 按钮将启动构建过程,并将其编程到创建的设置上。
2. 编程完成后,点击右上角面板中的工具图标,选择 UART 终端
3. 打开 UART 终端标签后,首先在选项菜单中检查波特率设置(默认是 115200)。如果该参数正确,通过点击 "CONNECT" 按钮激活终端。
4. 现在,终端状态从 Disconnected 变为绿色的 Connected,数据将显示在 Received data 字段中。
软件支持
库描述
该库包含 DC Motor 11 Click 驱动程序的 API。
关键功能:
dcmotor11_control
- 电机控制dcmotor11_get_fault
- 获取故障dcmotor11_get_interrupt_state
- INT引脚上的中断状态
开源
代码示例
这个示例可以在 NECTO Studio 中找到。欢迎下载代码,或者您也可以复制下面的代码。
/*!
* \file
* \brief DcMotor11 Click example
*
* # Description
* This application is motor driver with the current limiting and current sensing.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initialization driver init and sets first motor settings.
*
* ## Application Task
* Waits for valid user input and executes functions based on set of valid commands.
*
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "dcmotor11.h"
// ------------------------------------------------------------------ VARIABLES
static dcmotor11_t dcmotor11;
static log_t logger;
uint8_t motor_speed;
uint8_t motor_dir;
uint8_t f_motor_state = 1;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
dcmotor11_cfg_t cfg;
/**
* 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.
dcmotor11_cfg_setup( &cfg );
DCMOTOR11_MAP_MIKROBUS( cfg, MIKROBUS_1 );
dcmotor11_init( &dcmotor11, &cfg );
dcmotor11_get_fault( &dcmotor11 );
// Start settings
motor_dir = DCMOTOR11_DIRECTION_FORWARD;
motor_speed = DCMOTOR11_VSET_480mV;
dcmotor11_control( &dcmotor11, DCMOTOR11_DIRECTION_FORWARD, motor_speed );
}
void application_task ( void )
{
// Speed increase
motor_speed += 4;
if ( motor_speed >= DCMOTOR11_VSET_4820mV )
{
log_printf( &logger, "---- MAX SPEED ---- \r\n" );
motor_speed = DCMOTOR11_VSET_4820mV;
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
else
{
log_printf( &logger, "---- Speed increase ---- \r\n" );
log_printf( &logger, " MOTOR SPEED: %d \r\n", motor_speed );
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
// Speed decrease
motor_speed -= 4;
if ( motor_speed < DCMOTOR11_VSET_480mV )
{
log_printf( &logger, "---- MIN SPEED ---- \r\n" );
motor_speed = DCMOTOR11_VSET_480mV;
}
else
{
log_printf( &logger, "---- Speed decrease ---- \r\n");
log_printf( &logger, " MOTOR SPEED: %d \r\n", motor_speed );
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
// Stop / Start
if( f_motor_state == 1 )
{
log_printf( &logger,"---- Stop Motor!!! ---- \r\n" );
f_motor_state = 0;
dcmotor11_stop( &dcmotor11 );
}
else
{
log_printf( &logger,"---- Start Motor ---- \r\n" );
f_motor_state = 1;
motor_speed = DCMOTOR11_VSET_480mV;
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
// Direction - Forward / Backword
if ( motor_dir == 2 )
{
log_printf( &logger,"---- Direction - [FORWARD] ---- \r\n" );
motor_dir = 1;
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
else
{
log_printf( &logger,"---- Direction - [BACKWARD] ---- \r\n" );
motor_dir = 2;
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
/*!
* \file
* \brief DcMotor11 Click example
*
* # Description
* This application is motor driver with the current limiting and current sensing.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initialization driver init and sets first motor settings.
*
* ## Application Task
* Waits for valid user input and executes functions based on set of valid commands.
*
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "dcmotor11.h"
// ------------------------------------------------------------------ VARIABLES
static dcmotor11_t dcmotor11;
static log_t logger;
uint8_t motor_speed;
uint8_t motor_dir;
uint8_t f_motor_state = 1;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
dcmotor11_cfg_t cfg;
/**
* 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.
dcmotor11_cfg_setup( &cfg );
DCMOTOR11_MAP_MIKROBUS( cfg, MIKROBUS_1 );
dcmotor11_init( &dcmotor11, &cfg );
dcmotor11_get_fault( &dcmotor11 );
// Start settings
motor_dir = DCMOTOR11_DIRECTION_FORWARD;
motor_speed = DCMOTOR11_VSET_480mV;
dcmotor11_control( &dcmotor11, DCMOTOR11_DIRECTION_FORWARD, motor_speed );
}
void application_task ( void )
{
// Speed increase
motor_speed += 4;
if ( motor_speed >= DCMOTOR11_VSET_4820mV )
{
log_printf( &logger, "---- MAX SPEED ---- \r\n" );
motor_speed = DCMOTOR11_VSET_4820mV;
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
else
{
log_printf( &logger, "---- Speed increase ---- \r\n" );
log_printf( &logger, " MOTOR SPEED: %d \r\n", motor_speed );
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
// Speed decrease
motor_speed -= 4;
if ( motor_speed < DCMOTOR11_VSET_480mV )
{
log_printf( &logger, "---- MIN SPEED ---- \r\n" );
motor_speed = DCMOTOR11_VSET_480mV;
}
else
{
log_printf( &logger, "---- Speed decrease ---- \r\n");
log_printf( &logger, " MOTOR SPEED: %d \r\n", motor_speed );
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
// Stop / Start
if( f_motor_state == 1 )
{
log_printf( &logger,"---- Stop Motor!!! ---- \r\n" );
f_motor_state = 0;
dcmotor11_stop( &dcmotor11 );
}
else
{
log_printf( &logger,"---- Start Motor ---- \r\n" );
f_motor_state = 1;
motor_speed = DCMOTOR11_VSET_480mV;
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
// Direction - Forward / Backword
if ( motor_dir == 2 )
{
log_printf( &logger,"---- Direction - [FORWARD] ---- \r\n" );
motor_dir = 1;
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
else
{
log_printf( &logger,"---- Direction - [BACKWARD] ---- \r\n" );
motor_dir = 2;
dcmotor11_control( &dcmotor11, motor_dir, motor_speed );
}
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END