欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
STM32智能小車超聲波跟隨的程序源碼
[打印本頁]
作者:
zsmart
時間:
2018-7-16 09:29
標題:
STM32智能小車超聲波跟隨的程序源碼
#include "stm32f10x.h"
#include "delay.h"
#include "motor.h"
#include "keysacn.h"
#include "IRSEARCH.h"
#include "IRAvoid.h"
#include "usart.h"
#include "UltrasonicWave.h"
#include "timer.h"
#include "Server.h"
char ctrl_comm1 = COMM_STOP;//控制指令
char ctrl_comm1_last = COMM_STOP;//上一次的指令
int Q_temp,Q_temp_last,L_temp,R_temp;
// 超聲波轉頭函數
int front_detection()
{
// ZYSTM32_brake(0);
SetJointAngle(90);
delay_ms(100);
return UltrasonicWave_StartMeasure();
}
int left_detection()
{
// ZYSTM32_brake(0);
SetJointAngle(175);
delay_ms(300);
return UltrasonicWave_StartMeasure();
}
int right_detection()
{
// ZYSTM32_brake(0);
SetJointAngle(5);
delay_ms(300);
return UltrasonicWave_StartMeasure();
}
void BarrierProc(void)
{
delay_ms(10);
Q_temp_last = Q_temp;
Q_temp = front_detection();
printf("測到的距離值為:%d\n",Q_temp);
if( Q_temp > 45)
{
ctrl_comm1 = COMM_STOP;//防震蕩
return;
}
if((Q_temp_last > Q_temp)&&(Q_temp<=15)) ctrl_comm1 = COMM_DOWN;
//if(Q_temp<=15) ctrl_comm1 = COMM_DOWN;
if(Q_temp >=30) ctrl_comm1 = COMM_UP;
}
//extern int U_temp;
/*
void ZYSTM32_run(int speed,int time); //前進函數
void ZYSTM32_brake(int time); //剎車函數
void ZYSTM32_Left(int speed,int time); //左轉函數
void ZYSTM32_Spin_Left(int speed,int time); //左旋轉函數
void ZYSTM32_Right(int speed,int time); //右轉函數
void ZYSTM32_Spin_Right(int speed,int time);//右旋轉函數
void ZYSTM32_back(int speed,int time); //后退函數
*/
int main(void)
{
delay_init();
KEY_Init();
IRSearchInit();
IRAvoidInit();
Timerx_Init(5000,7199); //10Khz的計數頻率,計數到5000為500ms
UltrasonicWave_Configuration(); //對超聲波模塊初始化
uart_init(115200);
TIM4_PWM_Init(7199,0); //初始化PWM
TIM5_PWM_Init(9999,143); //不分頻,PWM頻率=72*10^6/(9999+1)/(143+1)=50Hz
ZYSTM32_brake(500);
keysacn();
while(1)
{
BarrierProc();
// Q_temp = front_detection();
// printf("測到的距離值為:%d\n",Q_temp);
//Q_temp_last = Q_temp;
//Q_temp = front_detection();
if(ctrl_comm1_last != ctrl_comm1)
{
ctrl_comm1_last = ctrl_comm1;
switch(ctrl_comm1)
{
case COMM_UP: ZYSTM32_run(50,10);break;
case COMM_DOWN: ZYSTM32_back(50,500); break;
case COMM_LEFT: ZYSTM32_Left(50,700);break;
case COMM_RIGHT:ZYSTM32_Right(50,700);break;
case COMM_STOP: ZYSTM32_brake(500);break;
default : break;
}
}
}
}
復制代碼
全部資料51hei下載地址:
ZYSTM32-A0 智能小車超聲波避障實驗(有舵機).rar
(311.8 KB, 下載次數: 89)
2018-7-16 17:13 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
ckeai
時間:
2018-12-9 20:58
新手求教 1.u_temp = UltrasonicWave_Distance*10;u_temp難道不是距離嗎?為什么不是直接賦值UltrasonicWave_Distance,還有乘以10
2. Q_temp_last = Q_temp;
Q_temp = front_detection();沒明白
3.為啥同樣是轉頭SetJointAngle()里的值還不一樣
4。SetJointAngle();這個函數沒看懂
作者:
vuckil
時間:
2018-12-24 20:02
參考學習下
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1