当前位置:网站首页>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
边栏推荐
- Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3
- ORA-01455: converting column overflows integer datatype
- juypter notebook 修改默认打开文件夹以及默认浏览器
- Excel finds the same value in a column, deletes the row or replaces it with a blank value
- GMapping代码解析[通俗易懂]
- [daily question] the next day
- 9D电影是怎样的?(+维度空间常识)
- Thread application instance
- Novice must see, click two buttons to switch to different content
- 开发固定资产管理系统,开发固定资产管理系统用什么语音
猜你喜欢
![[100 cases of JVM tuning practice] 02 - five cases of virtual machine stack and local method stack tuning](/img/59/6c776e0607a52962b72fbea2e64c8e.png)
[100 cases of JVM tuning practice] 02 - five cases of virtual machine stack and local method stack tuning

MySQL advanced learning summary 8: overview of InnoDB data storage structure page, internal structure of page, row format

论文导读 | 关于将预训练语言模型作为知识库的分析与批评

Transformation of thinking consciousness is the key to the success or failure of digital transformation of construction enterprises

Why should we build an enterprise fixed asset management system and how can enterprises strengthen fixed asset management

PHP-Parser羽毛球预约小程序开发require线上系统

思维意识转变是施工企业数字化转型成败的关键

Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径

codeforces每日5题(均1700)-第四天

Learning summary of MySQL advanced 6: concept and understanding of index, detailed explanation of b+ tree generation process, comparison between MyISAM and InnoDB
随机推荐
Learning summary of MySQL advanced 6: concept and understanding of index, detailed explanation of b+ tree generation process, comparison between MyISAM and InnoDB
教程篇(5.0) 09. RESTful API * FortiEDR * Fortinet 网络安全专家 NSE 5
横向越权与纵向越权[通俗易懂]
Tutorial (5.0) 09 Restful API * fortiedr * Fortinet network security expert NSE 5
Yunna | why use the fixed asset management system and how to enable it
The R language dplyr package rowwise function and mutate function calculate the maximum value of multiple data columns in each row in the dataframe data, and generate the data column (row maximum) cor
《病人家属,请来一下》读书笔记
QT中的QPropertyAnimation使用和toast案列
Date tool class (updated from time to time)
Yolov3 trains its own data set to generate train txt
Compile oglpg-9th-edition source code with clion
Kubernetes three open interfaces first sight
R language ggplot2 visual Facet: gganimate package is based on Transition_ Time function to create dynamic scatter animation (GIF)
Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径
Masa framework - DDD design (1)
codeforces每日5题(均1700)-第四天
使用xml文件打印mybaties-log插件的方式
How to delete the border of links in IE? [repeat] - how to remove borders around links in IE? [duplicate]
Mysql高级篇学习总结8:InnoDB数据存储结构页的概述、页的内部结构、行格式
2022.7.1-----leetcode.241