久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標題:
風力擺系統STM32源程序
[打印本頁]
作者:
Irontong
時間:
2020-5-8 14:04
標題:
風力擺系統STM32源程序
32單片機做的風力擺
單片機源程序如下:
#include "stm32f10x.h"
#include "oled.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "usart.h"
#include "mpu6050.h"
#include "inv_mpu.h"
#include "inv_mpu_dmp_motion_driver.h"
#include "other.h"
#include "motor.h"
#include "pid.h"
#include "timer.h"
#include "key.h"
#include "arithmetic.h"
#include <stdio.h>
#include <math.h>
volatile float last_pitch=0,last_roll=0,last_length_x=0,last_length_y=0;
//主函數中顯示數據共需要20ms左右的時間
/* pitch<0 1 |y pitch>0
roll<0 | roll<0
0~90度 | 90~180度
2 __第三象限 |____第四象限4 x
|
90~180度| 0~90度
第二象限pitch<0 | pitch>0第一象限
roll>0 |3 roll>0 */
//pitch: x軸角度,roll:y軸角度
int main(void)
{
volatile int key=0,mode=0;
float set_value_key[3]={0,0,0};
volatile float set_length=0,set_angle=0,set_radius=0,set_value=0;
Key_Config(); //按鍵初始化
uart_init(115200);//串口初始化,波特率為115200
delay_init(); //延時初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //設置NVIC中斷分組2:2位搶占優先級,2位響應優先級
motor_init(); //空心杯初始化
TIM2_PWM_Init(9999,71);//頻率f=72000000/10000/72=100
TIM3_Int_Init(1999,719);//定時器中斷,周期為20ms
motor_a(1,0);motor_c(1,0);
motor_b(1,0);motor_d(1,0);
initial_lcd(); //OLED初始化
// delay_ms(500);
MPU_Init(); //初始化MPU6050
while(mpu_dmp_init())
{
delay_ms(200);
display_GB2312_string(0,72,"error");
}
clear_screen();
display_GB2312_string(0,1,"風力擺");
display_GB2312_string(0,72,"OK");
while(1)
{
key=KeyScan();
if(key>10) {mode=key-10;key_count--;}
switch (mode)
{ case 1: {display_GB2312_string(2,1,"模式一:直線");break;}
case 2:{display_GB2312_string(2,1,"模式二:直線");display_GB2312_string(4,1,"設置長度:");
set_length=set_value/10;oled_display_set_length(4,84,set_length);break;}
case 3:{display_GB2312_string(2,1,"模式三:斜線");display_GB2312_string(4,1,"設置角度:");
set_angle=set_value; oled_display_set_angle(4,84,set_angle);break;}
case 4: {display_GB2312_string(2,1,"模式四:制動");break;}
case 5:{display_GB2312_string(2,1,"模式五:畫圓");display_GB2312_string(4,1,"設置半徑:");
set_radius=set_value/10;oled_display_set_radius(4,84,set_radius);break;}}
if((key>=0)&&(key<10))
{set_value_key[key_count-1]=key;set_value=set_value_key[0]*100+set_value_key[1]*10+set_value_key[2];}
if(key==10) break;
}
display_GB2312_string(6,1,"設置完畢");
// motor_init(); //空心杯初始化
// motor_a(1,0);motor_c(1,0);
// motor_b(1,0);motor_d(1,0);
while(1)
{
printf("%d ",mode);
while(mode==1){first();}
while(mode==2){second(set_length);}
while(mode==3){third(set_angle);}
while(mode==4){fourth();}
while(mode==5){fifth(set_radius);}
}
}
//定時器3中斷服務程序
void TIM3_IRQHandler(void) //TIM3 中斷
{
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //檢查TIM3更新中斷是否發生
{
TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //清除TIM3更新中斷標志
pid_flag=0;
current_stright_speed_x=(length_x-last_length_x)/0.02;
current_stright_speed_y=(length_y-last_length_y)/0.02;//計算速度,單位為cm/s
last_length_x=length_x;
last_length_y=length_y;
printf("中斷開");
current_angle_speed_x=(pitch-last_pitch)/0.02;
current_angle_speed_y=(roll-last_roll)/0.02;//計算速度,單位為度/s
last_pitch=pitch;
last_roll=roll;
}
}
復制代碼
所有程序51hei提供下載:
風力擺控制系統.zip
(399 KB, 下載次數: 32)
2020-5-8 14:04 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
久久久久久亚洲精品
|
久久在线视频
|
久久久女女女女999久久
|
在线亚洲一区二区
|
欧美在线
|
国产伦精品一区二区三区高清
|
日日操夜夜操天天操
|
中文天堂网
|
亚洲成av人片在线观看
|
丝袜 亚洲 欧美 日韩 综合
|
av网站观看
|
婷婷免费视频
|
不卡一区
|
一级做a爰片性色毛片16美国
|
日日天天
|
理论片87福利理论电影
|
国产97视频在线观看
|
日韩中文字幕一区
|
欧美自拍网站
|
亚洲aⅴ
|
亚洲国产情侣自拍
|
亚洲一区二区三区免费在线观看
|
日韩中文字幕久久
|
欧美日韩综合
|
国产精品美女一区二区
|
二区在线观看
|
亚洲精品一区二区三区在线观看
|
免费观看黄色一级片
|
亚洲精品一区二三区不卡
|
国产福利在线
|
午夜精品视频一区
|
免费看黄色视屏
|
欧美在线一区二区三区
|
久久国产精品一区二区三区
|
中文字幕日韩专区
|
涩涩视频在线观看
|
亚洲电影一区
|
国产精品毛片无码
|
伊人狼人影院
|
精品国产乱码久久久
|
中文字幕 欧美 日韩
|