Skip to content

Commit

Permalink
make max torque 200Nm
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbrook committed Jul 12, 2024
1 parent 0020dbb commit 13a3683
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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};

Expand Down
2 changes: 2 additions & 0 deletions src/inverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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())
{
Expand Down

0 comments on commit 13a3683

Please sign in to comment.