欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
基于MPU6050的二輪平衡車 STM32程序
[打印本頁]
作者:
鄧海鵬
時間:
2019-7-18 21:03
標題:
基于MPU6050的二輪平衡車 STM32程序
基于MPU6050的二輪平衡車,注釋比較多,方便理解。
單片機源程序如下:
/******************** (C) COPYRIGHT (2015)BST BALANCECAR **************************
* 文件名 :main.c
**********************************************************************************/
#include "stm32f10x.h"
#include "mpu6050.h"
#include "i2c_mpu6050.h"
#include "motor.h"
#include "upstandingcar.h"
#include "SysTick.h"
#include "led.h"
#include "usart.h"
#include "i2c.h"
#include "outputdata.h"
#include "timer.h"
#include "UltrasonicWave.h"
#include "stm32f10x_usart.h"
float gyz;
int acc;
int acc1;
/*協議相關*/
//extern u8 newLineReceived = 0;
/*
* 函數名:main
* 描述 :主函數
*/
int main(void)
{
SystemInit(); //=====系統初始化
Timerx_Init(5000,7199); //定時器TIM1
UltrasonicWave_Configuration(); //超聲波初始化設置 IO口及中斷設置
USART1_Config(); //串口1初始化 上位機
USART3_Config(); //串口3初始化 藍牙與USART3公用相同IO口
TIM2_PWM_Init(); //PWM輸出初始化
MOTOR_GPIO_Config(); //電機IO口初始化
LED_GPIO_Config();
TIM3_External_Clock_CountingMode(); //左電機脈沖輸出外部中斷口PA7使用TIM3定時器用作為脈沖數計算
TIM4_External_Clock_CountingMode(); //右電機脈沖輸出外部中斷口PB7使用TIM4定時器用作為脈沖數計算
TIM3_Encoder_Init(); //編碼器獲取脈沖數 PA6 7
TIM4_Encoder_Init(); //編碼器獲取脈沖數 PB6 7
////////////////////DMP/////////////////////////////////
i2cInit(); //IIC初始化 用于掛靠在總線上的設備使用
delay_nms(10); //延時10ms
MPU6050_Init(); //MPU6050 DMP陀螺儀初始化
SysTick_Init(); //SysTick函數初始化
CarUpstandInit(); //小車直立參數初始化
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; //使能總算法時鐘
while (1)
{
GPIO_ResetBits(GPIOC, GPIO_Pin_13);
MPU6050_Pose(); //獲取MPU6050角度狀態
gy0=gyro[0];
// UltrasonicWave_StartMeasure(); //調用超聲波發送程序 給Trig腳 <10us 高電平
// chaoshengbo(); //計算超聲波測距距離
// printf("%d",ucBluetoothValue);
// printf("\t");
// printf("%f",BST_fSpeedControlOutNew);
// printf("\t");
// printf("%f",BST_fCarAngle);
// printf("\t");
// printf("%f",BST_fLeftMotorOut);
// printf("\t");
// printf("\n");
if (newLineReceived)
{
ProtocolCpyData();
Protocol();
}
/*通過狀態控制小車*/
CarStateOut();
SendAutoUp();
}
}
復制代碼
所有資料51hei提供下載:
STM32平衡車.7z
(500.19 KB, 下載次數: 93)
2019-7-18 21:32 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
帕里亞奇
時間:
2019-11-30 16:58
你好,程序我有下載,我想問一下里面編碼器讀取到的數據在哪有用到的?
作者:
帕里亞奇
時間:
2019-11-30 17:00
本帖最后由 帕里亞奇 于 2019-12-11 20:42 編輯
霍爾編碼器也適用嗎?
作者:
善良仁
時間:
2020-1-12 19:06
這個貼子不錯,真心收藏了。
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1