欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 基于MPU6050的二輪平衡車 STM32程序 [打印本頁]

作者: 鄧海鵬    時間: 2019-7-18 21:03
標題: 基于MPU6050的二輪平衡車 STM32程序
基于MPU6050的二輪平衡車,注釋比較多,方便理解。

單片機源程序如下:
  1. /******************** (C) COPYRIGHT (2015)BST BALANCECAR **************************
  2. * 文件名  :main.c
  3. **********************************************************************************/
  4. #include "stm32f10x.h"
  5. #include "mpu6050.h"
  6. #include "i2c_mpu6050.h"
  7. #include "motor.h"
  8. #include "upstandingcar.h"
  9. #include "SysTick.h"
  10. #include "led.h"
  11. #include "usart.h"
  12. #include "i2c.h"
  13. #include "outputdata.h"
  14. #include "timer.h"
  15. #include "UltrasonicWave.h"
  16. #include "stm32f10x_usart.h"

  17. float gyz;
  18. int acc;
  19. int acc1;

  20. /*協議相關*/
  21. //extern u8 newLineReceived = 0;

  22. /*
  23. * 函數名:main
  24. * 描述  :主函數
  25. */
  26. int main(void)
  27. {       
  28.       
  29.        
  30.           SystemInit();                   //=====系統初始化
  31.         Timerx_Init(5000,7199);                                   //定時器TIM1
  32.         UltrasonicWave_Configuration();            //超聲波初始化設置 IO口及中斷設置                            

  33.         USART1_Config();                                                //串口1初始化 上位機
  34.         USART3_Config();                                                //串口3初始化 藍牙與USART3公用相同IO口
  35.        
  36.         TIM2_PWM_Init();                                           //PWM輸出初始化
  37.         MOTOR_GPIO_Config();                                  //電機IO口初始化
  38.           LED_GPIO_Config();
  39.        
  40.    TIM3_External_Clock_CountingMode();           //左電機脈沖輸出外部中斷口PA7使用TIM3定時器用作為脈沖數計算
  41.    TIM4_External_Clock_CountingMode();           //右電機脈沖輸出外部中斷口PB7使用TIM4定時器用作為脈沖數計算
  42.           TIM3_Encoder_Init();                       //編碼器獲取脈沖數 PA6 7
  43.           TIM4_Encoder_Init();                       //編碼器獲取脈沖數 PB6 7       
  44.         ////////////////////DMP/////////////////////////////////
  45.         i2cInit();                                                           //IIC初始化 用于掛靠在總線上的設備使用
  46.         delay_nms(10);                                                   //延時10ms
  47.         MPU6050_Init();                                                   //MPU6050 DMP陀螺儀初始化
  48.        
  49.         SysTick_Init();                                                  //SysTick函數初始化       
  50.         CarUpstandInit();                                          //小車直立參數初始化
  51.         SysTick->CTRL |=  SysTick_CTRL_ENABLE_Msk;         //使能總算法時鐘

  52.         while (1)
  53.         {

  54.                 GPIO_ResetBits(GPIOC, GPIO_Pin_13);
  55.                         MPU6050_Pose();                                                 //獲取MPU6050角度狀態
  56.                 gy0=gyro[0];
  57. //                 UltrasonicWave_StartMeasure();           //調用超聲波發送程序 給Trig腳 <10us 高電平                 
  58. //                 chaoshengbo();                               //計算超聲波測距距離
  59. //    printf("%d",ucBluetoothValue);
  60. //                printf("\t");
  61. //                printf("%f",BST_fSpeedControlOutNew);
  62. //                printf("\t");
  63. //                printf("%f",BST_fCarAngle);
  64. //                printf("\t");
  65. //                 printf("%f",BST_fLeftMotorOut);
  66. //                printf("\t");
  67. //                printf("\n");
  68.                
  69.                 if (newLineReceived)
  70.                    {
  71.                         ProtocolCpyData();
  72.                         Protocol();
  73.                 }
  74.                 /*通過狀態控制小車*/
  75.                 CarStateOut();
  76.                
  77.                 SendAutoUp();
  78.                
  79.                          
  80.          }
  81.                                                                     
  82. }
復制代碼

所有資料51hei提供下載:
STM32平衡車.7z (500.19 KB, 下載次數: 93)




作者: 帕里亞奇    時間: 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