曲率pid输出存在越界
This commit is contained in:
@@ -6,17 +6,17 @@
|
||||
#define FAN_LL_PWM_PIN TIM8_PWM_MAP1_CH1_B6 // 左升力风扇
|
||||
#define FAN_RL_PWM_PIN TIM8_PWM_MAP1_CH2_B7 // 右升力风扇
|
||||
// M4
|
||||
#define FAN_LB_PWM_A_PIN TIM10_PWM_MAP3_CH2_D3 // 左侧动力风扇
|
||||
#define FAN_LB_PWM_B_PIN TIM10_PWM_MAP3_CH4_D7 // 左侧动力风扇
|
||||
#define FAN_LB_PWM_A_PIN TIM10_PWM_MAP3_CH2_D3 // 左后
|
||||
#define FAN_LB_PWM_B_PIN TIM10_PWM_MAP3_CH4_D7 // 左后
|
||||
// M1
|
||||
#define FAN_RB_PWM_A_PIN TIM4_PWM_MAP1_CH1_D12 // 右侧动力风扇
|
||||
#define FAN_RB_PWM_B_PIN TIM4_PWM_MAP1_CH3_D14 // 右侧动力风扇
|
||||
#define FAN_RB_PWM_A_PIN TIM4_PWM_MAP1_CH1_D12 // 右后
|
||||
#define FAN_RB_PWM_B_PIN TIM4_PWM_MAP1_CH3_D14 // 右后
|
||||
// M3
|
||||
#define FAN_LS_PWM_A_PIN TIM10_PWM_MAP3_CH1_D1 // 左后动力风扇
|
||||
#define FAN_LS_PWM_B_PIN TIM10_PWM_MAP3_CH3_D5 // 左后动力风扇
|
||||
#define FAN_LS_PWM_A_PIN TIM10_PWM_MAP3_CH3_D5 // 左侧
|
||||
#define FAN_LS_PWM_B_PIN TIM10_PWM_MAP3_CH1_D1 // 左侧
|
||||
// M2
|
||||
#define FAN_RS_PWM_A_PIN TIM4_PWM_MAP1_CH4_D15 // 右后动力风扇
|
||||
#define FAN_RS_PWM_B_PIN TIM4_PWM_MAP1_CH2_D13 // 右后动力风扇
|
||||
#define FAN_RS_PWM_A_PIN TIM4_PWM_MAP1_CH4_D15 // 右侧
|
||||
#define FAN_RS_PWM_B_PIN TIM4_PWM_MAP1_CH2_D13 // 右侧
|
||||
|
||||
int32_t pwm_duty_ls_g;
|
||||
int32_t pwm_duty_rs_g;
|
||||
@@ -41,40 +41,24 @@ inline static float clip_f32(float x, float low, float up)
|
||||
: x);
|
||||
}
|
||||
|
||||
#define FIX_DRIVE 0
|
||||
|
||||
void by_pwm_init(void)
|
||||
{
|
||||
pwm_init(FAN_LL_PWM_PIN, 50, 500);
|
||||
pwm_init(FAN_RL_PWM_PIN, 50, 500);
|
||||
|
||||
// 测试鸣叫
|
||||
// pwm_init(FAN_LS_PWM_A_PIN, 1500, 1000);
|
||||
// pwm_init(FAN_LS_PWM_B_PIN, 4000, 0);
|
||||
// pwm_init(FAN_RS_PWM_A_PIN, 1500, 1000);
|
||||
// pwm_init(FAN_RS_PWM_B_PIN, 4000, 0);
|
||||
// pwm_init(FAN_LB_PWM_A_PIN, 1500, 1000);
|
||||
// pwm_init(FAN_LB_PWM_B_PIN, 4000, 0);
|
||||
// pwm_init(FAN_RB_PWM_A_PIN, 1500, 1000);
|
||||
// pwm_init(FAN_RB_PWM_B_PIN, 4000, 0);
|
||||
// system_delay_ms(100);
|
||||
// pwm_init(FAN_LS_PWM_A_PIN, 2000, 1000);
|
||||
// pwm_init(FAN_LS_PWM_B_PIN, 4000, 0);
|
||||
// pwm_init(FAN_RS_PWM_A_PIN, 2000, 1000);
|
||||
// pwm_init(FAN_RS_PWM_B_PIN, 4000, 0);
|
||||
// pwm_init(FAN_LB_PWM_A_PIN, 2000, 1000);
|
||||
// pwm_init(FAN_LB_PWM_B_PIN, 4000, 0);
|
||||
// pwm_init(FAN_RB_PWM_A_PIN, 2000, 1000);
|
||||
// pwm_init(FAN_RB_PWM_B_PIN, 4000, 0);
|
||||
// system_delay_ms(100);
|
||||
// pwm_init(FAN_LS_PWM_A_PIN, 2500, 1000);
|
||||
// pwm_init(FAN_LS_PWM_B_PIN, 4000, 0);
|
||||
// pwm_init(FAN_RS_PWM_A_PIN, 2500, 1000);
|
||||
// pwm_init(FAN_RS_PWM_B_PIN, 4000, 0);
|
||||
// pwm_init(FAN_LB_PWM_A_PIN, 2500, 1000);
|
||||
// pwm_init(FAN_LB_PWM_B_PIN, 4000, 0);
|
||||
// pwm_init(FAN_RB_PWM_A_PIN, 2500, 1000);
|
||||
// pwm_init(FAN_RB_PWM_B_PIN, 4000, 0);
|
||||
// system_delay_ms(100);
|
||||
|
||||
#if FIX_DRIVE==1
|
||||
pwm_init(FAN_LS_PWM_A_PIN, 12000, 1000);
|
||||
pwm_init(FAN_LS_PWM_B_PIN, 12000, 1000);
|
||||
pwm_init(FAN_RS_PWM_A_PIN, 12000, 1000);
|
||||
pwm_init(FAN_RS_PWM_B_PIN, 12000, 1000);
|
||||
pwm_init(FAN_LB_PWM_A_PIN, 12000, 1000);
|
||||
pwm_init(FAN_LB_PWM_B_PIN, 12000, 1000);
|
||||
pwm_init(FAN_RB_PWM_A_PIN, 12000, 1000);
|
||||
pwm_init(FAN_RB_PWM_B_PIN, 12000, 1000);
|
||||
while (1);
|
||||
#endif
|
||||
pwm_init(FAN_LS_PWM_A_PIN, 12000, 0);
|
||||
pwm_init(FAN_LS_PWM_B_PIN, 12000, 0);
|
||||
pwm_init(FAN_RS_PWM_A_PIN, 12000, 0);
|
||||
@@ -83,18 +67,7 @@ void by_pwm_init(void)
|
||||
pwm_init(FAN_LB_PWM_B_PIN, 12000, 0);
|
||||
pwm_init(FAN_RB_PWM_A_PIN, 12000, 0);
|
||||
pwm_init(FAN_RB_PWM_B_PIN, 12000, 0);
|
||||
// while (1);
|
||||
// system_delay_ms(3000);
|
||||
// // pwm_init(FAN_LS_PWM_PIN, 50, 1000); // 动力风扇左 1
|
||||
// // pwm_init(FAN_RS_PWM_PIN, 50, 1000); // 动力风扇右 1
|
||||
// // pwm_init(FAN_LB_PWM_PIN, 50, 1000); // 动力风扇左 2
|
||||
// // pwm_init(FAN_RB_PWM_PIN, 50, 1000); // 动力风扇右 2
|
||||
// // system_delay_ms(5000);
|
||||
// pwm_set_duty(FAN_LS_PWM_PIN, 600);
|
||||
// pwm_set_duty(FAN_RS_PWM_PIN, 600);
|
||||
// pwm_set_duty(FAN_LB_PWM_PIN, 600);
|
||||
// pwm_set_duty(FAN_RB_PWM_PIN, 600);
|
||||
// while(1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,10 +94,10 @@ void by_pwm_update_duty(uint32_t update_pwm_duty1, uint32_t update_pwm_duty2)
|
||||
*/
|
||||
void by_pwm_power_duty(int32_t bpwm_duty_ls, int32_t bpwm_duty_rs, int32_t bpwm_duty_lb, int32_t bpwm_duty_rb)
|
||||
{
|
||||
// bpwm_duty_ls = clip_s32(bpwm_duty_ls, 0, 5000);
|
||||
// bpwm_duty_rs = clip_s32(bpwm_duty_rs, 0, 5000);
|
||||
// bpwm_duty_lb = clip_s32(bpwm_duty_lb, -3000, 8000);
|
||||
// bpwm_duty_rb = clip_s32(bpwm_duty_rb, -3000, 8000);
|
||||
bpwm_duty_ls = clip_s32(bpwm_duty_ls, -9000, 9000);
|
||||
bpwm_duty_rs = clip_s32(bpwm_duty_rs, -9000, 9000);
|
||||
bpwm_duty_lb = clip_s32(bpwm_duty_lb, -9000, 9000);
|
||||
bpwm_duty_rb = clip_s32(bpwm_duty_rb, -9000, 9000);
|
||||
|
||||
// pwm_duty_ls_g = pwm_duty_ls;
|
||||
// pwm_duty_rs_g = pwm_duty_rs;
|
||||
|
||||
Reference in New Issue
Block a user