From 13a3683c4a073a3829eff52df4d7a60ee3c6184d Mon Sep 17 00:00:00 2001 From: Mathewos Samson Date: Thu, 11 Jul 2024 21:49:14 -0400 Subject: [PATCH] make max torque 200Nm --- include/parameters.hpp | 6 +++--- src/inverter.cpp | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/parameters.hpp b/include/parameters.hpp index 1ef6ca4..73018d7 100644 --- a/include/parameters.hpp +++ b/include/parameters.hpp @@ -19,7 +19,7 @@ #define D_KI 0.3 #define D_KD 0.5 #define D_OUTPUT_MIN 0.0 // Minimum output of the PID controller -#define D_OUTPUT_MAX 1600 // Max output of the PID controller +#define D_OUTPUT_MAX 2000 // Max output of the PID controller #define BANGBANG_RANGE 1000.0 #define PID_TIMESTEP 100.0 #define PID_MODE false //enable cruise control @@ -76,8 +76,8 @@ const double FILTERING_ALPHA_1HZ = 2 * 3.14 * cutoff_1hz / (1 + 2 * 3.14 * cutof // So it will overflow past a value of 255 const uint8_t TORQUE_1 = 10; // 1st Torque setting const uint8_t TORQUE_2 = 54; //2nd torque setting -const uint8_t TORQUE_3 = 110; //3rd torque setting -const uint8_t TORQUE_4 = 160; //4th torque setting +const uint8_t TORQUE_3 = 160; //3rd torque setting +const uint8_t TORQUE_4 = 200; //4th torque setting // List of torque modes (Nm) const int torque_mode_list[]={TORQUE_1,TORQUE_2,TORQUE_3,TORQUE_4}; diff --git a/src/inverter.cpp b/src/inverter.cpp index f41f67d..ec24cbb 100644 --- a/src/inverter.cpp +++ b/src/inverter.cpp @@ -107,6 +107,7 @@ void Inverter::writeEnableNoTorque() */ bool Inverter::command_torque(int16_t torque) { + uint16_t max_torque = TORQUE_4 * 10; // For now, this will not allow negative torque (regen) if (torque > (TORQUE_4 * 10)) { @@ -123,6 +124,7 @@ bool Inverter::command_torque(int16_t torque) uint8_t torqueCommand[] = { 0, 0, angularVelocity1, angularVelocity2, emraxDirection, inverterEnable, 0, 0}; memcpy(&torqueCommand[0], &torque, sizeof(torque)); + memcpy(&torqueCommand[6],&max_torque, sizeof(max_torque)); // Send torque command if timer has fired if (timer_motor_controller_send->check()) {