Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TEST NA CITANIE XACTUAL
- // Get the current position and send it over UART
- if(HAL_GetTick() - lastTick2>= interval2)
- {
- lastTick2 = HAL_GetTick();
- resultInteger = getPosition(MOTOR3);
- sprintf(msgXActual, "XActual %d\r\n", resultInteger);
- HAL_UART_Transmit_IT(&huart2, (uint8_t*)msgXActual, strlen(msgXActual));
- }
- if(HAL_GetTick() - lastTick >= interval)
- {
- lastTick = HAL_GetTick();
- // Get the current position and send it over UART
- // Change direction based on current direction.
- // You may include additional conditions based on resultInteger if needed.
- if(resultInteger == 0){
- poloha = 1000;
- rychlost = 200;
- setPos(poloha, rychlost, MOTOR3);
- }else if(resultInteger == 1000){
- poloha = 2000;
- rychlost = 300;
- setPos(poloha, rychlost, MOTOR3);
- }else if(resultInteger == 2000){
- poloha = 3000;
- rychlost = 500;
- setPos(poloha, rychlost, MOTOR3);
- }else if(resultInteger == 3000){
- poloha = 4000;
- rychlost = 700;
- setPos(poloha, rychlost, MOTOR3);
- }else if(resultInteger == 4000){
- poloha = 5000;
- rychlost = 1000;
- setPos(poloha, rychlost, MOTOR3);
- }else if(resultInteger == 5000){
- poloha = 0;
- rychlost = 800;
- setPos(poloha, rychlost, MOTOR3);
- }
- //
- // if(resultInteger >= 5000)
- // {
- // direction = false;
- // setPos(0, 400, MOTOR3);
- // }
- // else if(resultInteger <= 0)
- // {
- // direction = true;
- // setPos(5000, 400, MOTOR3);
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement