mirror of https://github.com/rusefi/bldc.git
Some fixes
This commit is contained in:
parent
58258d5efa
commit
e24b555dea
|
@ -136,7 +136,7 @@ static void process_packet(unsigned char *buffer, unsigned char len) {
|
|||
|
||||
switch (buffer[0]) {
|
||||
case UARTCOMM_CMD_SET_DUTY:
|
||||
mcpwm_set_duty((float)buffer_get_int16(buffer, &ind) / 1000.0);
|
||||
mcpwm_set_duty((float)buffer_get_int32(buffer, &ind) / 100000.0);
|
||||
last_uart_update_time = chTimeNow();
|
||||
break;
|
||||
|
||||
|
|
12
buffer.c
12
buffer.c
|
@ -64,18 +64,18 @@ uint16_t buffer_get_uint16(const uint8_t *buffer, int32_t *index) {
|
|||
|
||||
int32_t buffer_get_int32(const uint8_t *buffer, int32_t *index) {
|
||||
int32_t res = ((uint32_t) buffer[*index]) << 24 |
|
||||
((uint32_t) buffer[*index]) << 16 |
|
||||
((uint32_t) buffer[*index]) << 8 |
|
||||
((uint32_t) buffer[*index + 1]);
|
||||
((uint32_t) buffer[*index + 1]) << 16 |
|
||||
((uint32_t) buffer[*index + 2]) << 8 |
|
||||
((uint32_t) buffer[*index + 3]);
|
||||
*index += 4;
|
||||
return res;
|
||||
}
|
||||
|
||||
uint32_t buffer_get_uint32(const uint8_t *buffer, int32_t *index) {
|
||||
uint32_t res = ((uint32_t) buffer[*index]) << 24 |
|
||||
((uint32_t) buffer[*index]) << 16 |
|
||||
((uint32_t) buffer[*index]) << 8 |
|
||||
((uint32_t) buffer[*index + 1]);
|
||||
((uint32_t) buffer[*index + 1]) << 16 |
|
||||
((uint32_t) buffer[*index + 2]) << 8 |
|
||||
((uint32_t) buffer[*index + 3]);
|
||||
*index += 4;
|
||||
return res;
|
||||
}
|
||||
|
|
5
mcpwm.c
5
mcpwm.c
|
@ -588,8 +588,7 @@ void mcpwm_set_brake_current(float current) {
|
|||
if (state != MC_STATE_RUNNING) {
|
||||
// In case the motor is already spinning, set the state to running
|
||||
// so that it can be ramped down before the full brake is applied.
|
||||
// TODO: The number 500 is a hack...
|
||||
if (fabsf(rpm_now) > 500) {
|
||||
if (fabsf(rpm_now) > MCPWM_CURR_MIN_RPM_FBRAKE) {
|
||||
state = MC_STATE_RUNNING;
|
||||
} else {
|
||||
full_brake_ll();
|
||||
|
@ -853,7 +852,7 @@ static void set_duty_cycle_hl(float dutyCycle) {
|
|||
} else {
|
||||
// In case the motor is already spinning, set the state to running
|
||||
// so that it can be ramped down before the full brake is applied.
|
||||
if (fabsf(rpm_now) > MCPWM_MIN_RPM) {
|
||||
if (fabsf(rpm_now) > MCPWM_CURR_MIN_RPM_FBRAKE) {
|
||||
state = MC_STATE_RUNNING;
|
||||
} else {
|
||||
full_brake_ll();
|
||||
|
|
Loading…
Reference in New Issue