Skip to content

Commit

Permalink
Update example tune for new gyro, change air mode to avoid motors sto…
Browse files Browse the repository at this point in the history
…pping in extreme cases
  • Loading branch information
catphish committed Sep 23, 2023
1 parent 1c9b1d3 commit 0c37d7a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ term in the case of sudden yaw disruption.
## TBS Source One V5 5" - 2306/2555KV Motors at 4S

```
Angle rate: 1500
Acro rate: 1500
P: 120
I: 50
D: 150
Angle rate: 1000
Acro rate: 1000
P: 100
I: 80
D: 100
Yaw P: 200
Yaw I: 200
Yaw I: 100
Expo: 60
Yaw expo: 60
Throttle gain: 80
Expand Down
59 changes: 29 additions & 30 deletions firmware/src/airmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,6 @@
// throttle is close the the minimum or maximum.

void air_mode(int32_t *motor_outputs) {
// TODO: Make the limits configurable.
if(motor_outputs[1] < 100) {
int32_t motor_error = 100 - motor_outputs[1];
motor_outputs[1] = 100;
motor_outputs[2] += motor_error;
motor_outputs[3] += motor_error;
motor_outputs[4] += motor_error;
}
if(motor_outputs[2] < 100) {
int32_t motor_error = 100 - motor_outputs[2];
motor_outputs[2] = 100;
motor_outputs[1] += motor_error;
motor_outputs[3] += motor_error;
motor_outputs[4] += motor_error;
}
if(motor_outputs[3] < 100) {
int32_t motor_error = 100 - motor_outputs[3];
motor_outputs[3] = 100;
motor_outputs[1] += motor_error;
motor_outputs[2] += motor_error;
motor_outputs[4] += motor_error;
}
if(motor_outputs[4] < 100) {
int32_t motor_error = 100 - motor_outputs[4];
motor_outputs[4] = 100;
motor_outputs[1] += motor_error;
motor_outputs[2] += motor_error;
motor_outputs[3] += motor_error;
}

if(motor_outputs[1] > 2000) {
int32_t motor_error = motor_outputs[1] - 2000;
motor_outputs[1] = 2000;
Expand Down Expand Up @@ -65,4 +35,33 @@ void air_mode(int32_t *motor_outputs) {
motor_outputs[2] -= motor_error;
motor_outputs[3] -= motor_error;
}

if(motor_outputs[1] < 100) {
int32_t motor_error = 100 - motor_outputs[1];
motor_outputs[1] = 100;
motor_outputs[2] += motor_error;
motor_outputs[3] += motor_error;
motor_outputs[4] += motor_error;
}
if(motor_outputs[2] < 100) {
int32_t motor_error = 100 - motor_outputs[2];
motor_outputs[2] = 100;
motor_outputs[1] += motor_error;
motor_outputs[3] += motor_error;
motor_outputs[4] += motor_error;
}
if(motor_outputs[3] < 100) {
int32_t motor_error = 100 - motor_outputs[3];
motor_outputs[3] = 100;
motor_outputs[1] += motor_error;
motor_outputs[2] += motor_error;
motor_outputs[4] += motor_error;
}
if(motor_outputs[4] < 100) {
int32_t motor_error = 100 - motor_outputs[4];
motor_outputs[4] = 100;
motor_outputs[1] += motor_error;
motor_outputs[2] += motor_error;
motor_outputs[3] += motor_error;
}
}

0 comments on commit 0c37d7a

Please sign in to comment.