当前位置:网站首页>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 .
边栏推荐
- unity Hub 登錄框變得很窄 無法登錄
- Yyds dry goods inventory student attendance system based on QT design
- PCL least median square method fitting plane
- Classifier visual interpretation stylex: Google, MIT, etc. have found the key attributes that affect image classification
- 分析超700万个研发需求发现,这8门编程语言才是行业最需要的!
- Cloud native cicd framework: Tekton
- Yyds dry inventory executor package (parameter processing function)
- 电脑设备打印机驱动安装失败如何解决
- mysql min() 求某条件下最小的值出现多个结果
- Unity Json 编写
猜你喜欢

Yyds dry goods inventory # look up at the sky | talk about the way and principle of capturing packets on the mobile terminal and how to prevent mitm

unity Hub 登录框变得很窄 无法登录

TCP拥塞控制详解 | 2. 背景

Does bone conduction earphone have external sound? Advantages of bone conduction earphones

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

What is the difference between self attention mechanism and fully connected graph convolution network (GCN)?

Yyds dry inventory method of deleting expired documents in batch

⌈ 2022 ⌋ how to use webp gracefully in projects

头条 | 亚控科技产品入选中纺联《纺织服装行业数字化转型解决方案重点推广名录》

渗透工具-内网权限维持-Cobalt strike
随机推荐
How to use stustr function in Oracle view
[fluent] dart data type number type (DART file creation | num type | int type | double type | num related API)
Global and Chinese markets for airport baggage claim conveyors 2022-2028: technology, participants, trends, market size and share Research Report
PCL 点云镜像变换
Which software is good for machine vision?
LeetCode 4. Find the median (hard) of two positive arrays
sim2real环境配置教程
Penetration tool - intranet permission maintenance -cobalt strike
What is the difference between self attention mechanism and fully connected graph convolution network (GCN)?
LeetCode 3. 无重复字符的最长子串
AcWing 300. Task arrangement
La boîte de connexion du hub de l'unit é devient trop étroite pour se connecter
Some problems about MySQL installation
LeetCode 4. 寻找两个正序数组的中位数(hard)
False summer vacation
The login box of unity hub becomes too narrow to log in
Take you ten days to easily complete the go micro service series (I)
pwm呼吸灯
LeetCode 1. 两数之和
Yyds dry goods inventory has not revealed the artifact? Valentine's Day is coming. Please send her a special gift~