当前位置:网站首页>A4988 drive stepper motor "recommended collection"
A4988 drive stepper motor "recommended collection"
2022-07-02 19:21:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
A4988 It's usually used arduino To drive , I use STM32F103 Driven .
First push a web page ,https://www.pololu.com/product/1182, There are more detailed and professional instructions on it , There is also a video explanation about limiting current to make subdivision more accurate , All in all , major . Then push one datasheet,https://www.pololu.com/file/0J450/a4988_DMOS_microstepping_driver_with_translator.pdf
I use it
The driver is easy to write , First of all, make sure the wiring mode .
Code :
motor.c
//IO initialization
void MOTOR_Init(void)
{
RCC->APB2ENR|=1<<3;
GPIOB->CRH&=0xff000000;
GPIOB->CRH|=0x00333333;
}
// To subdivide
// x==1 Full step
// x==2 half of step
// x==4 1/4 Step
// x==8 1/8 Step
// x==16 1/16 Step
void Step_Micr(u16 x)
{
switch(x)
{
case 1:Full_step;break;
case 2:Half_step;break;
case 4:Quarter_step;break;
case 8:Eighth_step;break;
case 16:Sixteenth_step;break;
default:break;
}
}
// Parameters
// dir:FALSE Positive rotation TRUE reverse
// period cycle
// step pulse
void Step_Control(u8 dir,u16 period,u32 steps)
{
u32 i;
for(i=0; i <= steps;i++)
{
DIR = dir;
STEP = 1;
delay_us(1);
STEP = 0;
delay_us(period);//periodԽС£¬×ªËÙÔ½¿ì£¬²»ÒªÐ¡ÓÚ1000
}
}
// This function can be locked
// 0 Cling to death
// 1 normal
void Step_Enable()
{
ENABLE = 0;
}
motor.h
#define STEP PBout(8) //step
#define DIR PBout(9) //dir
#define MS1 PBout(10)//MS1
#define MS2 PBout(11)//MS2
#define MS3 PBout(12)//MS3
#define ENABLE PBout(13)//ENABLE
// Subdivision macro definition
#define Full_step {MS1 = 0;MS2 = 0;MS3 = 0;}
#define Half_step {MS1 = 1;MS2 = 0;MS3 = 0;}
#define Quarter_step {MS1 = 0;MS2 = 1;MS3 = 0;}
#define Eighth_step {MS1 = 1;MS2 = 1;MS3 = 0;}
#define Sixteenth_step {MS1 = 1;MS2 = 1;MS3 = 1;}
void MOTOR_Init(void);
void Step_Micr(u16 x);
void Step_Enable(void);
void Step_Control(u8 dir,u16 period,u32 steps);
main.c
int main(void)
{
int i=0;
Stm32_Clock_Init(9);
delay_init(72);
MOTOR_Init();
Step_Micr(1);//1/2/4/8/16
for(i=0;i<10;i++)
{
Step_Control(FALSE,1600,200);// Positive rotation
delay_ms(1000);
Step_Control(TRUE,1600,200);// reverse
delay_ms(1000);
}
Step_Enable();// Cling to death
while(1)
{
}
}
Realize a positive turn in the full step state , Turn around , Hold on for a while and then lock up .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/148605.html Link to the original text :https://javaforall.cn
边栏推荐
- Why should we build an enterprise fixed asset management system and how can enterprises strengthen fixed asset management
- 线程应用实例
- 从list转化成map的时候,如果根据某一属性可能会导致key重复而异常,可以设置处理这种重复的方式
- MySQL advanced learning summary 8: overview of InnoDB data storage structure page, internal structure of page, row format
- Data dimensionality reduction principal component analysis
- PHP parser badminton reservation applet development requires online system
- 数据降维——主成分分析
- 【测试开发】一文带你了解什么是软件测试
- The difference between interceptor and filter
- PyTorch函数中的__call__和forward函数
猜你喜欢
医院在线问诊源码 医院视频问诊源码 医院小程序源码
聊聊电商系统中红包活动设计
Codeworks 5 questions per day (1700 average) - day 4
How performance testing creates business value
Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径
STM32G0 USB DFU 升级校验出错-2
Tutorial (5.0) 09 Restful API * fortiedr * Fortinet network security expert NSE 5
According to the atlas of data security products and services issued by the China Academy of information technology, meichuang technology has achieved full coverage of four major sectors
PHP parser badminton reservation applet development requires online system
教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 網絡安全專家 NSE 5
随机推荐
MySQL advanced (Advanced) SQL statement
【JVM调优实战100例】01——JVM的介绍与程序计数器
2022 software engineering final exam recall Edition
Processing strategy of message queue message loss and repeated message sending
Advanced performance test series "24. Execute SQL script through JDBC"
论文导读 | 机器学习在数据库基数估计中的应用
论文导读 | 关于将预训练语言模型作为知识库的分析与批评
为什么要做企业固定资产管理系统,企业如何加强固定资产管理
Fastdfs installation
数据降维——因子分析
使用xml文件打印mybaties-log插件的方式
机器学习笔记 - 时间序列预测研究:法国香槟的月销量
#gStore-weekly | gStore源码解析(四):安全机制之黑白名单配置解析
[0701] [paper reading] allowing data imbalance issue with perforated input during influence
二进制操作
教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 網絡安全專家 NSE 5
End-to-End Object Detection with Transformers(DETR)论文阅读与理解
SIFT特征点提取「建议收藏」
PyTorch函数中的__call__和forward函数
Excel查找一列中的相同值,删除该行或替换为空值