mirror of
https://github.com/DashyFox/StackSport.git
synced 2025-05-04 15:20:16 +00:00
min speed fix
This commit is contained in:
parent
c7876a00c5
commit
251da124f7
@ -643,27 +643,35 @@ void setScrewkSpeed(uint8_t speed) {
|
|||||||
|
|
||||||
//(-v) 0 .. 100(stop) .. 200(+v)
|
//(-v) 0 .. 100(stop) .. 200(+v)
|
||||||
void setRollersSpeed(uint8_t up, uint8_t down) {
|
void setRollersSpeed(uint8_t up, uint8_t down) {
|
||||||
|
uint16_t min_speed_rpm = map(infoBlock.hwInfo.motors.speed_Rollers_min, 0, 200, 400, 800);
|
||||||
|
uint16_t min_speed_pwm_positive = map(min_speed_rpm, 0, 8000, 100, 200);
|
||||||
|
uint16_t min_speed_pwm_negative = 100 - map(min_speed_rpm, 0, 8000, 0, 100);
|
||||||
|
|
||||||
if (up < 100) {
|
if (up == 100) {
|
||||||
// up = map(up, 0, 100, 0, 100 - infoBlock.hwInfo.motors.speed_Screw_min);
|
up = 100;
|
||||||
// if (100 - up < min_speed) {
|
} else if (up > 100) {
|
||||||
// up = 100 - min_speed;
|
|
||||||
// }
|
if (up < min_speed_pwm_positive) {
|
||||||
|
up = min_speed_pwm_positive;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// up = map(up, 0, 100, 0, 100 + infoBlock.hwInfo.motors.speed_Screw_min);
|
if (up > min_speed_pwm_negative) {
|
||||||
// if (up - 100 < min_speed) { // Ограничиваем положительную скорость минимальной
|
up = min_speed_pwm_negative;
|
||||||
// up = 100 + min_speed;
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (down < 100) {
|
if (down == 100) {
|
||||||
// map(down, 0, 100, 0, 100 - infoBlock.hwInfo.motors.speed_Screw_min);
|
down = 100;
|
||||||
|
} else if (down > 100) {
|
||||||
|
if (down < min_speed_pwm_positive) {
|
||||||
|
down = min_speed_pwm_positive;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// map(down, 0, 100, 0, 100 + infoBlock.hwInfo.motors.speed_Screw_min);
|
if (down > min_speed_pwm_negative) {
|
||||||
|
down = min_speed_pwm_negative;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vz1 = 200 - up; // invert
|
Vz1 = 200 - up; // Инвертируем значение скорости для одного из моторов
|
||||||
Vz2 = down;
|
Vz2 = down;
|
||||||
}
|
}
|
||||||
|
@ -422,10 +422,13 @@ void UART3_GetStartupDelay(uint8_t *dataPtr, uint8_t len) {
|
|||||||
|
|
||||||
// 210 !!!!!!!!
|
// 210 !!!!!!!!
|
||||||
void UART3_SetMinRollerSpeed(uint8_t *dataPtr, uint8_t len) {
|
void UART3_SetMinRollerSpeed(uint8_t *dataPtr, uint8_t len) {
|
||||||
const uint8_t MIN_PARAM_LENGTH = 0;
|
const uint8_t MIN_PARAM_LENGTH = 1;
|
||||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
infoBlock.hwInfo.motors.speed_Rollers_min = dataPtr[1];
|
||||||
|
saveInfoBlock();
|
||||||
|
|
||||||
SendResponse(dataPtr[0], 0, NULL, 0);
|
SendResponse(dataPtr[0], 0, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,8 +438,7 @@ void UART3_GetMinRollerSpeed(uint8_t *dataPtr, uint8_t len) {
|
|||||||
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
if (!checkLen(dataPtr[0], len, MIN_PARAM_LENGTH))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint8_t res[1];
|
uint8_t res[1] = {infoBlock.hwInfo.motors.speed_Rollers_min};
|
||||||
// res[0] = ;
|
|
||||||
|
|
||||||
SendResponse(dataPtr[0], 0, res, sizeof(res));
|
SendResponse(dataPtr[0], 0, res, sizeof(res));
|
||||||
}
|
}
|
||||||
|
@ -222,23 +222,21 @@ int main(void)
|
|||||||
// printNumber(SysTick->LOAD);
|
// printNumber(SysTick->LOAD);
|
||||||
// CDC_Transmit_FS(text, sizeof(text));
|
// CDC_Transmit_FS(text, sizeof(text));
|
||||||
|
|
||||||
// char buffer[100]; // Буфер для формата строки
|
char buffer[100];
|
||||||
|
extern uint32_t vsk1;
|
||||||
|
extern uint32_t vsk2;
|
||||||
|
extern uint16_t timing1;
|
||||||
|
extern uint16_t timing2;
|
||||||
|
sprintf(buffer,
|
||||||
|
"timing1: %u ms, timing2: %u ms, vsk1: %u RPM, vsk2: %u RPM\n",
|
||||||
|
timing1, timing2, vsk1, vsk2);
|
||||||
|
CDC_Transmit_FS((uint8_t*) buffer, strlen(buffer));
|
||||||
|
|
||||||
// extern uint32_t vsk1;
|
// char buffer[64];
|
||||||
// extern uint32_t vsk2;
|
// sprintf(buffer, "Current mode: %s, Current state: %s\n",
|
||||||
// extern uint16_t timing1;
|
// getModeString(currentInfo.mode),
|
||||||
// extern uint16_t timing2;
|
// getStateString(currentInfo.state));
|
||||||
// sprintf(buffer,
|
// CDC_Transmit_FS((uint8_t*)buffer, strlen(buffer));
|
||||||
// "timing1: %u ms, timing2: %u ms, vsk1: %u RPM, vsk2: %u RPM\n",
|
|
||||||
// timing1, timing2, vsk1, vsk2);
|
|
||||||
//
|
|
||||||
// CDC_Transmit_FS((uint8_t*) buffer, strlen(buffer));
|
|
||||||
|
|
||||||
char buffer[64];
|
|
||||||
sprintf(buffer, "Current mode: %s, Current state: %s\n",
|
|
||||||
getModeString(currentInfo.mode),
|
|
||||||
getStateString(currentInfo.state));
|
|
||||||
CDC_Transmit_FS((uint8_t*)buffer, strlen(buffer));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user