当前位置:网站首页>PWM controlled steering gear
PWM controlled steering gear
2022-07-02 16:43:00 【Let everything burn】
Mission requirements
Use PWM Control the steering gear to rotate at any angle within the steering gear angle range . matters needing attention
: Try not to use external force to prevent the steering gear from rotating , Avoid damage to the single chip . Acceptance requirements
:
initial position 0°, Press the button ( You can customize any key ) rotate 30°, If you end up turning , Turn into pressing the button to turn in the opposite direction 30°
Press a key repeatedly , From 0 Change to the maximum angle and return to 0
Ideas
Need to use 30°
So use the original
0° 1500 0.5ms
45° 3000 1ms
……
Calculate the proportion
You can estimate
30.06 2502 0.834 1002
The whole cycle is 20ms, Overflow value is 60000
0 0.5ms 1500
180 2.5ms 7500
Overflow time =(arr+1)(psc+1)/Tclk
20MS = (59999+1)*(23+1)/72000000
Finished code
int main (void){
// Defining variables must be placed first
u16 t = 1500;
u8 dir = 1;
delay_ms(500);
RCC_Configuration();
RELAY_Init();
I2C_Configuration();
TOUCH_KEY_Init();// Initialize touch button
TIM3_PWM_Init(59999,23);
// Make the initial situation 0°
TIM_SetCompare3(TIM3,1500);
while(1){
delay_ms(10);
// Positive direction , Press the key every time 30°
if(dir){
for(t=1500;t<7500;){
if(!GPIO_ReadInputDataBit(TOUCH_KEYPORT,TOUCH_KEY_B)){
if(!GPIO_ReadInputDataBit(TOUCH_KEYPORT,TOUCH_KEY_B)){
t=t+1002;// It needs to be done first ++ Then execute, so write the code here
TIM_SetCompare3(TIM3,t);
while(!GPIO_ReadInputDataBit(TOUCH_KEYPORT,TOUCH_KEY_B));
}
}
}
}
if(t==7500)dir=0;
// Negative direction , Press the key every time 30°
else{
for(t=7500;t>1500;){
if(!GPIO_ReadInputDataBit(TOUCH_KEYPORT,TOUCH_KEY_B)){
if(!GPIO_ReadInputDataBit(TOUCH_KEYPORT,TOUCH_KEY_B)){
t=t-1002;
TIM_SetCompare3(TIM3,t);
while(!GPIO_ReadInputDataBit(TOUCH_KEYPORT,TOUCH_KEY_B));
}
}
}
}
if(t==1500)dir=1;// Corresponding to the previous one if The statement needs to be written in if(dir) Outside , Otherwise, the loop cannot jump out
}
}
Because you need to go every time you press the key 30° So the key should be locked , The principle is the same as the previous mechanical key locking . But touching the button does not need to delay to eliminate jitter .
边栏推荐
- sql解决连续登录问题变形-节假日过滤
- Global and Chinese markets for airport baggage claim conveyors 2022-2028: technology, participants, trends, market size and share Research Report
- SSM整合-异常处理器及项目异常处理方案
- Multi task prompt learning: how to train a large language model?
- Kubernetes family container housekeeper pod online Q & A?
- 数学分析_笔记_第5章:一元微分学
- Privacy computing technology innovation and industry practice seminar: Learning
- Original God 2.6 server download and installation tutorial
- Yyds dry goods inventory hands-on teaching you to carry out the packaging and release of mofish Library (fishing Library)
- Take you ten days to easily complete the go micro service series (I)
猜你喜欢
总结|机器视觉中三大坐标系及其相互关系
一文读懂AGV的关键技术——激光SLAM与视觉SLAM的区别
The login box of unity hub becomes too narrow to log in
HMS core machine learning service helps zaful users to shop conveniently
Interview summary of large factories
Unity使用UGUI设置一个简单多级水平方向下拉菜单(不需要代码)
What if the win11 app store cannot load the page? Win11 store cannot load page
只是巧合?苹果iOS16的神秘技术竟然与中国企业5年前产品一致!
Ranger (I) preliminary perception
Seal Library - installation and introduction
随机推荐
Data security industry series Salon (III) | data security industry standard system construction theme Salon
Student course selection system (curriculum design of Shandong Agricultural University)
La boîte de connexion du hub de l'unit é devient trop étroite pour se connecter
Global and Chinese markets for slotting milling machines 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets for carbon dioxide laser cutting heads 2022-2028: Research Report on technology, participants, trends, market size and share
mysql min() 求某条件下最小的值出现多个结果
HMS core machine learning service helps zaful users to shop conveniently
Written by unity Jason
OSPF - route aggregation [(summary) including configuration commands] | address summary calculation method - detailed explanation
大廠面試總結大全
Original God 2.6 server download and installation tutorial
LeetCode 5. Longest Palindromic Substring
Mysql database mysqldump why there is no statement to create a database
路由模式:hash和history模式
Global and Chinese markets for airport baggage claim conveyors 2022-2028: technology, participants, trends, market size and share Research Report
TypeScript数组乱序输出
LeetCode 6. Zigzag transformation (n-shaped transformation)
做机器视觉哪个软件好?
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
PCL least median square method fitting plane