Advertisement
goodvibes2298

Tuto to fungovalo XACTUAL

Mar 26th, 2025
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1.  
  2.  
  3.         // TEST NA CITANIE XACTUAL
  4.         // Get the current position and send it over UART
  5.         if(HAL_GetTick() - lastTick2>= interval2)
  6.         {
  7.             lastTick2 = HAL_GetTick();
  8.             resultInteger = getPosition(MOTOR3);
  9.             sprintf(msgXActual, "XActual %d\r\n", resultInteger);
  10.             HAL_UART_Transmit_IT(&huart2, (uint8_t*)msgXActual, strlen(msgXActual));
  11.  
  12.  
  13.         }
  14.  
  15.  
  16.         if(HAL_GetTick() - lastTick >= interval)
  17.         {
  18.             lastTick = HAL_GetTick();
  19.  
  20.             // Get the current position and send it over UART
  21.  
  22.  
  23.             // Change direction based on current direction.
  24.             // You may include additional conditions based on resultInteger if needed.
  25.             if(resultInteger == 0){
  26.                 poloha = 1000;
  27.                 rychlost = 200;
  28.                 setPos(poloha, rychlost, MOTOR3);
  29.             }else if(resultInteger == 1000){
  30.                 poloha = 2000;
  31.                 rychlost = 300;
  32.                 setPos(poloha, rychlost, MOTOR3);
  33.             }else if(resultInteger == 2000){
  34.                 poloha = 3000;
  35.                 rychlost = 500;
  36.                 setPos(poloha, rychlost, MOTOR3);
  37.             }else if(resultInteger == 3000){
  38.                 poloha = 4000;
  39.                 rychlost = 700;
  40.                 setPos(poloha, rychlost, MOTOR3);
  41.             }else if(resultInteger == 4000){
  42.                 poloha = 5000;
  43.                 rychlost = 1000;
  44.                 setPos(poloha, rychlost, MOTOR3);
  45.             }else if(resultInteger == 5000){
  46.                 poloha = 0;
  47.                 rychlost = 800;
  48.                 setPos(poloha, rychlost, MOTOR3);
  49.             }
  50. //
  51. //          if(resultInteger >= 5000)
  52. //          {
  53. //              direction = false;
  54. //              setPos(0, 400, MOTOR3);
  55. //          }
  56. //          else if(resultInteger <= 0)
  57. //          {
  58. //              direction = true;
  59. //              setPos(5000, 400, MOTOR3);
  60. //          }
  61.         }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement