Skip to content

Commit

Permalink
pid changes2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Teppen108 committed May 31, 2024
1 parent 5a4a3d1 commit e06db0b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
16 changes: 8 additions & 8 deletions software/MySrc/Flight/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

void mixing(mixer_handle_t *mixer_h, motor_output_t *motor_output){
int16_t motor_low_limit = 200;
int16_t motor_high_limit = 1850;
int16_t motor_high_limit = 1600;

float throttle = ((float)mixer_h->input.throttle)*mixer_h->percentages.throttle;
float roll = ((float)mixer_h->input.roll)* mixer_h->percentages.roll;
Expand All @@ -13,10 +13,10 @@ void mixing(mixer_handle_t *mixer_h, motor_output_t *motor_output){



motor_output->motor4 = (int16_t)((throttle + roll- pitch - yaw)); //must be motor 4 was motor 1
motor_output->motor3 = (int16_t)((throttle - roll - pitch + yaw)); //must be motor 3 was motor 2
motor_output->motor1 = (int16_t)((throttle - roll + pitch - yaw)); //must be motor 1 was motor 3
motor_output->motor2 = (int16_t)((throttle + roll + pitch + yaw)); //must be motor 2 was motor 4
motor_output->motor4 = (int16_t)((throttle + pitch + roll - yaw)); //must be motor 4 was motor 1
motor_output->motor3 = (int16_t)((throttle - pitch + roll + yaw)); //must be motor 3 was motor 2
motor_output->motor1 = (int16_t)((throttle - pitch - roll - yaw)); //must be motor 1 was motor 3
motor_output->motor2 = (int16_t)((throttle + pitch - roll + yaw)); //must be motor 2 was motor 4

if(motor_output->motor1 > motor_high_limit){
temp = motor_output->motor1 - motor_high_limit;
Expand Down Expand Up @@ -128,8 +128,8 @@ void mixing(mixer_handle_t *mixer_h, motor_output_t *motor_output){
}

void init_mixer_percentages(mixer_handle_t *mixer_h){
mixer_h->percentages.roll = 0.8;
mixer_h->percentages.roll = 1;
mixer_h->percentages.pitch = 0.8;
mixer_h->percentages.yaw = 0.8;
mixer_h->percentages.throttle = 0.8;
mixer_h->percentages.yaw = 1;
mixer_h->percentages.throttle = 1;
}
6 changes: 3 additions & 3 deletions software/MySrc/Flight/pid_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@


#define TAU 0.00065
#define KD 0.6
#define KI 0.4
#define KP 1.2
#define KP 0.6
#define KI 0.2
#define KD 1.8



Expand Down
1 change: 1 addition & 0 deletions software/MySrc/mymain.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ void mymain(void) {

//imu_process(&imu_h);
flight_ctrl_cycle();

motors_process(&motors_h);


Expand Down

0 comments on commit e06db0b

Please sign in to comment.