updated params and speed settings

This commit is contained in:
jenoack 2023-03-17 09:27:57 +01:00
parent 839b687400
commit 3a88aac74a
2 changed files with 15 additions and 9 deletions

View file

@ -100,10 +100,10 @@ const uint8_t HALL6_PIN = 26;
const uint8_t HALL7_PIN = 27; const uint8_t HALL7_PIN = 27;
const uint8_t HALL8_PIN = 14; const uint8_t HALL8_PIN = 14;
const uint16_t MIN_SPEED = 600; const uint16_t MIN_SPEED = 500;
const uint16_t MAX_SPEED = 1200; const uint16_t MAX_SPEED = 3000;
const uint8_t MAX_ESC_SPEED = 60; const uint8_t MAX_ESC_SPEED = 100;
const uint8_t MIN_ESC_SPEED = 37; const uint8_t MIN_ESC_SPEED = 36;
const uint16_t MAX_POTI_VALUE = 4095; const uint16_t MAX_POTI_VALUE = 4095;
const uint16_t JITTER_POTI_PERCENT = 10; const uint16_t JITTER_POTI_PERCENT = 10;

View file

@ -19,9 +19,11 @@ volatile double goal_speed = 0;
volatile double current_speed = 0; volatile double current_speed = 0;
volatile double err = 0; volatile double err = 0;
volatile double output = 0.0; volatile double output = 0.0;
double kp = 0.005; double kp = 1;//0.005;
double ki = 0.0008; double ki = 1000;//0.0008;
double kd = 0.0001; double kd = 5;//0.0001;
//bei 2000 als speed: values: kp=0.020000 ki=0.005000 kd=0.000100
void ISR_HALL1(); void ISR_HALL1();
void ISR_HALL2(); void ISR_HALL2();
@ -320,15 +322,19 @@ void get_serial_cmd()
ki = command.substring(command.indexOf("=")+1).toDouble(); ki = command.substring(command.indexOf("=")+1).toDouble();
Serial.printf("Set ki to %f\n", ki); Serial.printf("Set ki to %f\n", ki);
} }
else if(command.startsWith("speed=")){ else if(command.startsWith("speed=")){
ser_speed = command.substring(command.indexOf("=")+1).toDouble(); ser_speed = command.substring(command.indexOf("=")+1).toDouble();
Serial.printf("Set speed to %f\n", speed); Serial.printf("Set speed to %f\n", ser_speed);
} }
else if(command.startsWith("kd=")){ else if(command.startsWith("kd=")){
kd = command.substring(command.indexOf("=")+1).toDouble(); kd = command.substring(command.indexOf("=")+1).toDouble();
Serial.printf("Set kd to %f\n", kd); Serial.printf("Set kd to %f\n", kd);
} }
else if(command.startsWith("esc=")){
ser_esc_output = command.substring(command.indexOf("=")+1).toDouble();
Serial.printf("Set esc_output to %f\n", ser_esc_output);
}
else if(command.equals("params")){ else if(command.equals("params")){
Serial.printf("Actual values: kp=%f ki=%f kd=%f \n", kp, ki, kd); Serial.printf("Actual values: kp=%f ki=%f kd=%f \n", kp, ki, kd);
} }