diff --git a/306-controller_interface.X/app/eeprom.c b/306-controller_interface.X/app/eeprom.c index 1f256f6..bd6dc71 100644 --- a/306-controller_interface.X/app/eeprom.c +++ b/306-controller_interface.X/app/eeprom.c @@ -24,7 +24,7 @@ void MEM_init(){ uint8_t check = MEM_read_1_byte(0x0); if(check != 0x42){ KART_CST.CONTROL_STEERING_MODE = 0; - KART_CST.CONTROL_ALIVE_TIME = 250; // should be 50 + KART_CST.CONTROL_ALIVE_TIME = 50; // should be 50 KART_CST.CONTROL_SPEED_FACTOR = 111111; // 111'111 KART_CST.CONTROL_POWER_FACTOR = 10000; // 10'000 KART_CST.CONTROL_STEERING_FACTOR = 5600240; // 5'600'024 diff --git a/306-controller_interface.X/app/factory/factory.c b/306-controller_interface.X/app/factory/factory.c index bc0d6db..f326b16 100644 --- a/306-controller_interface.X/app/factory/factory.c +++ b/306-controller_interface.X/app/factory/factory.c @@ -40,6 +40,7 @@ void Factory_init() { CAN_setSender(1); MEM_init(); + initRamp(); ALIVE_init(ALcontroller(), 6); ALIVE_setAliveTime(ALcontroller(), KART_CST.CONTROL_ALIVE_TIME); diff --git a/306-controller_interface.X/app/kartculator.c b/306-controller_interface.X/app/kartculator.c index f57f435..d4137e1 100644 --- a/306-controller_interface.X/app/kartculator.c +++ b/306-controller_interface.X/app/kartculator.c @@ -225,7 +225,9 @@ void calcTorque(uint8_t joy_pos) { if(joy_pos >= 0) { calcTorque = rampTorque[joy_pos]; } else { - calcTorque = -rampTorque[-joy_pos]; + joy_pos *= -1; + calcTorque = rampTorque[joy_pos]; + calcTorque *= -1; } calcTorque *= KART_CST.CONTROL_POWER_FACTOR; // convert by power factor calcTorque /= 1000; // torque define by joystick @@ -239,7 +241,9 @@ void calcPosition(uint8_t joy_pos){ if(joy_pos >= 0) { calcPosition = rampPosition[joy_pos]; } else { - calcPosition = -rampPosition[-joy_pos]; + joy_pos *= -1; + calcPosition = rampPosition[joy_pos]; + rampPosition *= -1; } calcPosition *= (int32_t) KART_CST.CONTROL_STEERING_FACTOR; calcPosition /= 1000; diff --git a/306-controller_interface.X/app/kartculator.h b/306-controller_interface.X/app/kartculator.h index cad450f..dcfd52c 100644 --- a/306-controller_interface.X/app/kartculator.h +++ b/306-controller_interface.X/app/kartculator.h @@ -13,6 +13,7 @@ #include "../mcc_generated_files/mcc.h" #include "car.h" +void initRamp(); void deadJoystick(void* p); void calcTorque(uint8_t joy_pos); void calcPosition(uint8_t joy_pos);