kopia lustrzana https://github.com/YohanHadji/R2Home
Finishing the servo fix
rodzic
aff1205bd6
commit
06edd6e779
|
@ -10,6 +10,8 @@ int SERVO_MAX_C = 0;
|
||||||
double Setpoint, Input, Output;
|
double Setpoint, Input, Output;
|
||||||
PID myPID(&Input, &Output, &Setpoint,NKP, NKI, NKD, DIRECT);
|
PID myPID(&Input, &Output, &Setpoint,NKP, NKI, NKD, DIRECT);
|
||||||
|
|
||||||
|
unsigned long time_gain = 0;
|
||||||
|
|
||||||
void navigation_setup() {
|
void navigation_setup() {
|
||||||
myPID.SetTunings(NKP, NKI, NKD);
|
myPID.SetTunings(NKP, NKI, NKD);
|
||||||
myPID.SetOutputLimits(-180, 180);
|
myPID.SetOutputLimits(-180, 180);
|
||||||
|
@ -29,7 +31,7 @@ void cmpt_weight_gain() {
|
||||||
int total_weight = SYSTEM_WEIGHT+PAYLOAD_WEIGHT;
|
int total_weight = SYSTEM_WEIGHT+PAYLOAD_WEIGHT;
|
||||||
total_weight = constrain(total_weight, 500, 1500);
|
total_weight = constrain(total_weight, 500, 1500);
|
||||||
SERVO_MAX_M_W = map(total_weight, 500, 1500, 2000, 1500);
|
SERVO_MAX_M_W = map(total_weight, 500, 1500, 2000, 1500);
|
||||||
SERVO_MAX_C_W = map(total_weight, 500, 1500, 1500, 1250);
|
SERVO_MAX_C_W = map(total_weight, 500, 1500, 2000, 1500);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SERVO_MAX_M_W = SERVO_MAX_M_DEF;
|
SERVO_MAX_M_W = SERVO_MAX_M_DEF;
|
||||||
|
@ -38,13 +40,18 @@ void cmpt_weight_gain() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmpt_pressure_gain(float pressure_ratio) {
|
void cmpt_pressure_gain(float pressure_ratio) {
|
||||||
if (AUTO_GAIN_PRESSURE) {
|
if (millis()-time_gain>1000) {
|
||||||
SERVO_MAX_M = map((SERVO_MAX_M_W-1000)/pressure_ratio, 0, 1000, 1000, 2000);
|
time_gain = millis();
|
||||||
SERVO_MAX_C = map((SERVO_MAX_M_W-1000)/pressure_ratio, 0, 1000, 1000, 1500);
|
if (AUTO_GAIN_PRESSURE) {
|
||||||
}
|
SERVO_MAX_M = map((SERVO_MAX_M_W-1000)/pressure_ratio, 0, 1000, 1000, 2000);
|
||||||
else {
|
SERVO_MAX_C = map((SERVO_MAX_M_W-1000)/pressure_ratio, 0, 1000, 1000, 2000);
|
||||||
SERVO_MAX_M = SERVO_MAX_M_W;
|
Serial.print(SERVO_MAX_M_W); Serial.print(","); Serial.print(SERVO_MAX_M); Serial.print(",");
|
||||||
SERVO_MAX_C = SERVO_MAX_C_W;
|
Serial.print(SERVO_MAX_C_W); Serial.print(","); Serial.println(SERVO_MAX_C);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SERVO_MAX_M = SERVO_MAX_M_W;
|
||||||
|
SERVO_MAX_C = SERVO_MAX_C_W;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ void getdata() {
|
||||||
|
|
||||||
void datacmpt() {
|
void datacmpt() {
|
||||||
|
|
||||||
cmpt_pressure_gain(pressure_baro);
|
cmpt_pressure_gain(pressure_sqrt_ratio());
|
||||||
|
|
||||||
if (new_cog) {
|
if (new_cog) {
|
||||||
new_cog = false;
|
new_cog = false;
|
||||||
|
|
Ładowanie…
Reference in New Issue