久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 984|回復: 0
打印 上一主題 下一主題
收起左側

control step servor

[復制鏈接]
跳轉到指定樓層
樓主
ID:963502 發表于 2021-9-2 11:08 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
kiểm soát demo bước Servor

  1. /* Includes ------------------------------------------------------------------*/
  2. #include "main.h"
  3. #include "uart.h"
  4. #include "control.h"


  5. /* Private function prototypes -----------------------------------------------*/
  6. void SystemClock_Config(void);

  7. int main(void)
  8. {

  9.   /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  10.   HAL_Init();

  11.   SystemClock_Config();

  12.   /* Initialize all configured peripherals */
  13.   MX_GPIO_Init();
  14.   MX_USART1_UART_Init();
  15.   MX_USART2_UART_Init();
  16.   /* USER CODE BEGIN 2 */
  17.   HAL_UART_Receive_IT(&huart2, (uint8_t*) &UART1_Data, 1);
  18.   /* USER CODE END 2 */
  19.    DWT_Delay_Init();
  20.    
  21.         
  22.   while (1)
  23.   {
  24.   
  25.    if(UART_Buffer[0]!=0){
  26.            sprintf(copy,"%s\r\n", UART_Buffer);
  27.                  
  28.            cpystr(&chuoi[0],substr(©[0],0,0));
  29.                   printf("%s\r\n",&chuoi[0]);
  30.                    home=chuoi[0];
  31. //                 ta=atoi(&n[0]);
  32.                   cpystr(&chuoi[1],substr(©[1],7,7));
  33.                   printf("%s\r\n",&chuoi[1]);
  34. //                  svong=atoi(&chuoi[1]);
  35.                          cpystr(&chuoi[2],substr(©[2],9,9));
  36.                   printf("%s\r\n",&chuoi[2]);
  37. //                   dir=atoi(&chuoi[2]);
  38.                  
  39.                  HAL_Delay(700);
  40.                  
  41.      if(copy[0]>0&&chuoi[0]>0){
  42.                    for(int h=0;h<100;h++){
  43.                            copy[h]=0;
  44.                                  chuoi[h]=0;
  45.                          }
  46.                   for(int p=0;p<100;p++){
  47.                           UART_Buffer[p]=0;
  48.                          }
  49.                  }
  50.          }
  51.      HAL_Delay(500);
  52. //=====================================================================================================
  53.          if(home=='h'){
  54.                  if(HAL_GPIO_ReadPin(STOP3_GPIO_Port,STOP3_Pin)==1&&HAL_GPIO_ReadPin(STOP2_GPIO_Port,STOP2_Pin)==1){
  55.              dc2(phai,1,100); // lui ve
  56.                  }
  57.                  else{
  58.                    stopdc2();
  59.                  }
  60.                  if(HAL_GPIO_ReadPin(STOP3_GPIO_Port,STOP3_Pin)==1&&HAL_GPIO_ReadPin(STOP2_GPIO_Port,STOP2_Pin)==0){
  61.              dc2(phai,1,100); // lui ve
  62.                  }
  63.                  else{
  64.                    stopdc2();
  65.                  }
  66.                  
  67.                  if(HAL_GPIO_ReadPin(STOP2_GPIO_Port,STOP2_Pin)==1&&HAL_GPIO_ReadPin(STOP3_GPIO_Port,STOP3_Pin)==0){
  68.                            dc1(trai,1,100); // lui ve   
  69.                  }
  70.                  else{
  71.                          stopdc1();
  72.                      }

  73.            if (HAL_GPIO_ReadPin(STOP2_GPIO_Port,STOP2_Pin)==0&&HAL_GPIO_ReadPin(STOP3_GPIO_Port,STOP3_Pin)==0){
  74.                      stopdc1();
  75.                            stopdc2();
  76.                             home=0;
  77.                  }
  78.          
  79.          }
  80.          else{
  81.             stopdc1();
  82.                   stopdc2();
  83.           }
  84. //=================================================================================================================
  85.          if(home=='r'){
  86.            if(HAL_GPIO_ReadPin(STOP2_GPIO_Port,STOP2_Pin)==0 && HAL_GPIO_ReadPin(STOP3_GPIO_Port,STOP3_Pin)==0)
  87.            {
  88.                        dc2(trai,7,40);
  89.                           if(HAL_GPIO_ReadPin(STOP2_GPIO_Port,STOP2_Pin)==0){
  90.                                         for(int k =0 ; k<9 ;k ++){
  91.                                                 vitriy(phai,20,50);
  92.                                                  HAL_Delay(700);
  93.                                                 
  94.                                         }
  95.                                         dc2(trai,3,40);
  96.                                        
  97.                                                 for(int lo =0 ; lo<9 ;lo++){
  98.                                                 vitriy(trai,20,50);
  99.                                                 HAL_Delay(700);
  100.                                         }
  101.                                                         dc2(trai,3,40);                                                                        
  102.                                        
  103.                                                 for(int m =0 ; m<9 ;m ++){
  104.                                                         vitriy(phai,20,50);
  105.                                                  HAL_Delay(700);                                                
  106.                                         }
  107.                                                 for(int dd =0 ; dd<9 ;dd ++){
  108.                                                         vitriy(trai,20,50);
  109.                                         }
  110.          if(HAL_GPIO_ReadPin(STOP2_GPIO_Port,STOP2_Pin)==0){
  111.                                          stopdc1();
  112.                                          dc2(phai,5,40);
  113.                                          dc2(phai,3,70);                                 
  114.                                          dc2(phai,3,90);
  115.                                          runx(100,2200);
  116.                                  }
  117.                                  else{
  118.                                    stopdc2();
  119.                                  }
  120.          if(HAL_GPIO_ReadPin(STOP2_GPIO_Port,STOP2_Pin)==0&&HAL_GPIO_ReadPin(STOP3_GPIO_Port,STOP3_Pin)==0){
  121.                                          HAL_Delay(500);
  122.                     stopdc2();
  123.                     stopdc1();
  124.                                            home=0;
  125.                                   }

  126.                          }  
  127.                  }
  128.          }
  129.                  else{
  130.                    stopdc1();
  131.                          stopdc2();
  132.                }
  133.                  
  134.          
  135.          

  136. //==========================================================================================
  137.                
  138.   }

  139. }



  140. void SystemClock_Config(void)
  141. {
  142.   RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  143.   RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  144.   /** Initializes the CPU, AHB and APB busses clocks
  145.   */
  146.   RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  147.   RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  148.   RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
  149.   RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  150.   RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  151.   RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  152.   RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  153.   if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  154.   {
  155.     Error_Handler();
  156.   }
  157.   /** Initializes the CPU, AHB and APB busses clocks
  158.   */
  159.   RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  160.                               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  161.   RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  162.   RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  163.   RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  164.   RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  165.   if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  166.   {
  167.     Error_Handler();
  168.   }
  169. }



  170. void Error_Handler(void)
  171. {
  172.   /* USER CODE BEGIN Error_Handler_Debug */
  173.   /* User can add his own implementation to report the HAL error return state */

  174.   /* USER CODE END Error_Handler_Debug */
  175. }

  176. #ifdef  USE_FULL_ASSERT
  177. /**
  178.   * @brief  Reports the name of the source file and the source line number
  179.   *         where the assert_param error has occurred.
  180.   * @param  file: pointer to the source file name
  181.   * @param  line: assert_param error line source number
  182.   * @retval None
  183.   */
  184. void assert_failed(uint8_t *file, uint32_t line)
  185. {
  186.   /* USER CODE BEGIN 6 */
  187.   /* User can add his own implementation to report the file name and line number,
  188.      tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  189.   /* USER CODE END 6 */
  190. }
  191. #endif /* USE_FULL_ASSERT */


復制代碼


control.7z

253.49 KB, 下載次數: 3, 下載積分: 黑幣 -5

評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 一级毛片视频 | 欧美日韩亚洲在线 | 亚洲毛片在线 | 免费v片在线观看 | 日日夜夜免费精品 | 神马九九| 亚洲在线成人 | 精品一二三区视频 | 日韩精品视频在线观看一区二区三区 | 国产精品欧美一区二区三区不卡 | 国产成人啪免费观看软件 | 国产成人免费视频网站高清观看视频 | 日韩成人影院在线观看 | a毛片| 欧美精品成人 | 91操操操 | 国产激情精品一区二区三区 | 在线看91 | 亚洲精彩免费视频 | 青青草华人在线视频 | 最新一级毛片 | 久久9精品 | 在线视频 中文字幕 | 欧美激情国产日韩精品一区18 | 日韩精品av | 国产精品久久在线 | 特级丰满少妇一级aaaa爱毛片 | 少妇无套高潮一二三区 | 日韩一区欧美一区 | 欧美 日韩 国产 成人 | 国产亚洲二区 | 久久免费精品 | 91高清视频在线观看 | 午夜成人免费视频 | 自拍 亚洲 欧美 老师 丝袜 | 黄色骚片 | 精品福利一区二区三区 | 中文字幕国产一区 | 韩国成人在线视频 | 亚洲va欧美va天堂v国产综合 | 成人依人 |