当前位置:网站首页>Analog rocker controlled steering gear
Analog rocker controlled steering gear
2022-07-04 22:39:00 【Let everything burn】
List of articles
Mission :
Potentiometer and steering gear combined application , If it is 180° The steering gear , The effective range of potentiometer is also 180°, If it is 90° The steering gear , The effective range of potentiometer is 90°, Potentiometer and steering gear angle position are synchronized , The effective starting point of potentiometer is self-determined , The finish for ( The starting point +90°/180°)
Ideas
The potentiometer on the yangtao development board is the omnidirectional rocker on the left , With rocker x Axis or y The axis controls the angle of the steering gear
For example, the rocker on the far left corresponds to the steering gear 0°, Pull to the rightmost steering gear and turn 180°
The angle of the steering gear is evenly distributed at the beginning and end of the rocker
The rocker is essentially an adjustable resistor , After the resistance voltage is divided, the single chip microcomputer can be used ADC Get location status
Completion code
int main (void){
// The main program
delay_ms(500); // Wait for other devices to be ready when powered on
RCC_Configuration(); // System clock initialization
TOUCH_KEY_Init();// Touch the button to initialize
RELAY_Init();// Relay initialization
TIM3_PWM_Init(59999,23);
ADC_Configuration(); //ADC Initialize settings ( Simulate the of the rocker ADC initialization )
JoyStick_Init(); // Simulate the key initialization of the rocker
I2C_Configuration();//I2C initialization
OLED0561_Init(); //OLED initialization
OLED_DISPLAY_8x16_BUFFER(0," YoungTalk "); // display string
OLED_DISPLAY_8x16_BUFFER(2," ADC TEST "); // display string
OLED_DISPLAY_8x16_BUFFER(4," ADC_IN6: "); // display string
OLED_DISPLAY_8x16_BUFFER(6," ADC_IN7: "); // display string
while(1){
// Turn the of the photoresist ADC The data is shown in OLED On
OLED_DISPLAY_8x16(4,10*8,ADC_DMA_IN[0]/1000+0x30);//
OLED_DISPLAY_8x16(4,11*8,ADC_DMA_IN[0]%1000/100+0x30);//
OLED_DISPLAY_8x16(4,12*8,ADC_DMA_IN[0]%100/10+0x30);//
OLED_DISPLAY_8x16(4,13*8,ADC_DMA_IN[0]%10+0x30);//
OLED_DISPLAY_8x16(6,10*8,ADC_DMA_IN[1]/1000+0x30);//
OLED_DISPLAY_8x16(6,11*8,ADC_DMA_IN[1]%1000/100+0x30);//
OLED_DISPLAY_8x16(6,12*8,ADC_DMA_IN[1]%100/10+0x30);//
OLED_DISPLAY_8x16(6,13*8,ADC_DMA_IN[1]%10+0x30);//
// Method 1 : Inter partition control ( Simple but troublesome )
// if(ADC_DMA_IN[0]<100)
// TIM_SetCompare3(TIM3,1500);
//
// if(ADC_DMA_IN[0]>=100&&ADC_DMA_IN[0]<1700)
// TIM_SetCompare3(TIM3,ADC_DMA_IN[0]+1500);
// if(ADC_DMA_IN[0]>=1700&&ADC_DMA_IN[0]<2000)
// TIM_SetCompare3(TIM3,ADC_DMA_IN[0]+2300);
//
// if( ADC_DMA_IN[0]>=2000&&ADC_DMA_IN[0]<3500)
// TIM_SetCompare3(TIM3,ADC_DMA_IN[0]+2500);
// if( ADC_DMA_IN[0]>=3500&&ADC_DMA_IN[0]<4000)
// TIM_SetCompare3(TIM3,ADC_DMA_IN[0]+3500);
//
// if( ADC_DMA_IN[0]>4000)
// TIM_SetCompare3(TIM3,7500);
// delay_ms(10);
// Method 2 : Write formula conversion ( Difficult but convenient )
TIM_SetCompare3(TIM3,ADC_DMA_IN[0]*(3.3/4096)*1820+1500);
if(GPIO_ReadInputDataBit(JoyStickPORT,JoyStick_KEY)==0){
OLED_DISPLAY_8x16(0,0,'Y');//
}else{
OLED_DISPLAY_8x16(0,0,' ');//
}
delay_ms(200); // Time delay
}
}
边栏推荐
- More than 30 institutions jointly launched the digital collection industry initiative. How will it move forward in the future?
- 页面关闭前,如何发送一个可靠请求
- LOGO special training camp section I identification logo and Logo Design Ideas
- Detailed explanation of flask context
- leetcode 72. Edit distance edit distance (medium)
- 质量体系建设之路的分分合合
- LOGO特训营 第五节 字体结构与设计常用技法
- Alibaba launched a new brand "Lingyang" and is committed to becoming a "digital leader"
- Mysql root 账号如何重置密码
- Logo special training camp Section V font structure and common design techniques
猜你喜欢
sobel过滤器
[Yugong series] go teaching course 003-ide installation and basic use in July 2022
攻防世界 MISC 进阶区 Erik-Baleog-and-Olaf
Naacl-22 | introduce the setting of migration learning on the prompt based text generation task
质量体系建设之路的分分合合
Embedded development: skills and tricks -- seven skills to improve the quality of embedded software code
SPSS installation and activation tutorial (including network disk link)
攻防世界 MISC 进阶区 3-11
Logo Camp d'entraînement section 3 techniques créatives initiales
LOGO特训营 第二节 文字与图形的搭配关系
随机推荐
Solana chain application crema was shut down due to hacker attacks
PHP short video source code, thumb animation will float when you like it
集群的概述与定义,一看就会
La prospérité est épuisée, les choses sont bonnes et mauvaises: Où puis - je aller pour un chef de station personnel?
啃下大骨头——排序(二)
More than 30 institutions jointly launched the digital collection industry initiative. How will it move forward in the future?
MYSQL架构——用户权限与管理
醒悟的日子,我是怎么一步一步走向软件测试的道路
Short video system source code, click the blank space of the screen, the keyboard does not automatically stow
Unity修仙手游 | lua动态滑动功能(3种源码具体实现)
Common shortcut keys for hbuilder x
Attack and defense world misc advanced area Hong
10 schemes to ensure interface data security
将QA引入软件开发生命周期是工程师要遵循的最佳实践
LOGO特訓營 第一節 鑒別Logo與Logo設計思路
[the 2023 autumn recruitment of MIHA tour] open [the only exclusive internal push code of school recruitment eytuc]
LOGO特训营 第二节 文字与图形的搭配关系
SQL中MAX与GREATEST的区别
idea中pom.xml依赖无法导入
It is said that software testing is very simple, but why are there so many dissuasions?