资源简介
镜头变焦步进电机芯片MP6507驱动芯片简单代码实现,基于STM32F30x
代码片段和文件信息
#include
#include “cam.h“
#include “stm32f30x.h“
#if ((defined(USING_LENS_STEP_MOTOR)))
#define MP_A1_Port GPIOB
#define MP_A1_Pin GPIO_Pin_12
#define MP_A2_Port GPIOB
#define MP_A2_Pin GPIO_Pin_13
#define MP_B1_Port GPIOB
#define MP_B1_Pin GPIO_Pin_14
#define MP_B2_Port GPIOB
#define MP_B2_Pin GPIO_Pin_15
#define MP_A1_SET() do{MP_A1_Port->BSRR = MP_A1_Pin;}while(0)
#define MP_A1_CLR() do{MP_A1_Port->BRR = MP_A1_Pin;}while(0)
#define MP_A2_SET() do{MP_A2_Port->BSRR = MP_A2_Pin;}while(0)
#define MP_A2_CLR() do{MP_A2_Port->BRR = MP_A2_Pin;}while(0)
#define MP_B1_SET() do{MP_B1_Port->BSRR = MP_B1_Pin;}while(0)
#define MP_B1_CLR() do{MP_B1_Port->BRR = MP_B1_Pin;}while(0)
#define MP_B2_SET() do{MP_B2_Port->BSRR = MP_B2_Pin;}while(0)
#define MP_B2_CLR() do{MP_B2_Port->BRR = MP_B2_Pin;}while(0)
#define MP_RCC (RCC_AHBPeriph_GPIOB)
#define MP_IDLE 0
#define MP_STOP 1
#define MP_RUNNING 2
#define MP_SPD_MIN 1
#define MP_SPD_MAX 8
#define MP_POS_MIN (0)
#define MP_POS_MIN_RE (268)
#define MP_POS_MIN_RE1 (396)//视场角70度
#define MP_POS_MIN_RE2 (298)//视场角75度
#define MP_POS_MAX (1120)
static int _mp_act = MP_IDLE;
int *_mp_act_init_stop = &_mp_act;
static int _mp_cnt = 0;
static int _mp_spd = 8;
static int _mp_pos = MP_POS_MIN;
static int _mp_tgt = MP_POS_MIN;
static struct timer _mp_timer;
static const uint8_t _mp_wave_tbl[] = {0x050x040x060x020x0A0x080x090x01};
/********************************************************
*
********************************************************/
static inline void mp_hw_pwm_set(int val)
{
if (val & 0x01)
MP_A1_SET();
else
MP_A1_CLR();
if (val & 0x02)
MP_A2_SET();
else
MP_A2_CLR();
if (val & 0x04)
MP_B1_SET();
else
MP_B1_CLR();
if (val & 0x08)
MP_B2_SET();
else
MP_B2_CLR();
}
/********************************************************
*
********************************************************/
static void _mp_hw_timeout_handler(void *parameter)
{
int idx;
switch (_mp_act)
{
case MP_IDLE:
break;
case MP_STOP:
mp_hw_pwm_set(0x00);
_mp_act = MP_IDLE;
break;
case MP_RUNNING:
if (_mp_cnt++ != (MP_SPD_MAX - _mp_spd))
break;
_mp_cnt = 0;
idx = _mp_pos & (sizeof(_mp_wave_tbl) - 1);
mp_hw_pwm_set(_mp_wave_tbl[idx]);
if (_mp_pos != _mp_tgt)
{
if (_mp_pos > _mp_tgt)
_mp_pos --;
else
_mp_pos ++;
}
else
{
_mp_act = MP_STOP;
}
break;
相关资源
- 基于STM32RCT6的步进电机驱动程序
- 带有死区延时的H桥直流电机驱动电路
- FPGA在步进电机驱动上的应用实例及代
- pwm控制驱动直流电机 可调速 可调转的
- 底盘电机驱动.zip
- TB6612FNG驱动电机
- STM32F1指南者步进电机驱动
- k60电机驱动程序
- 130ST-M15015 交流伺服电机驱动器使用说
- 硬石无刷电机驱动板原理图.rar
- 飞思卡尔BTN7971双电机驱动模块
- IR2110隔离型H桥驱动芯片应用电路
- 步进电机驱动芯片:L293D
- 51单片机驱动电机驱动模块
- 60W无刷直流 (BLDC) 电机驱动器参考
- stm32步进电机驱动,包括库函数和寄存
- 直流电机驱动器程序+电路工程图原创
- 智能步进电机驱控芯片TMC5160中文手册
- 电机驱动电路原理图和PCB图
- THB6128步进电机驱动电路
- 电机驱动程序基于STM32F1
- 智能小车黑白线识别寻光寻迹电机驱
- 恩智浦飞思卡尔电机驱动PCB板4路BTN
- verilog 串口 无刷直流电机驱动 PWM
- L298N_电机驱动模块_程序书
- MP6516-中文文档.pdf
- 步进电机驱动芯片THB6064H资料大全
- Labview电机驱动的论文
- 双电机驱动btn 飞思卡尔智能车
- 关于A4988步进电机驱动模块的使用心得
评论
共有 条评论