最新一般有刷加无刷
This commit is contained in:
@@ -78,10 +78,10 @@ void by_pwm_init(void)
|
||||
// pwm_init(FAN_LS_PWM_B_PIN, 40000, 0);
|
||||
// pwm_init(FAN_RS_PWM_A_PIN, 40000, 0);
|
||||
// pwm_init(FAN_RS_PWM_B_PIN, 40000, 0);
|
||||
pwm_init(FAN_LB_PWM_A_PIN, 50000, 0);
|
||||
pwm_init(FAN_LB_PWM_B_PIN, 50000, 0);
|
||||
pwm_init(FAN_RB_PWM_A_PIN, 50000, 0);
|
||||
pwm_init(FAN_RB_PWM_B_PIN, 50000, 0);
|
||||
pwm_init(FAN_LB_PWM_A_PIN, 40000, 0);
|
||||
pwm_init(FAN_LB_PWM_B_PIN, 40000, 0);
|
||||
pwm_init(FAN_RB_PWM_A_PIN, 40000, 0);
|
||||
pwm_init(FAN_RB_PWM_B_PIN, 40000, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,7 +104,6 @@ int32_t pwm_duty_ls;
|
||||
int32_t pwm_duty_rs;
|
||||
int32_t pwm_duty_lb;
|
||||
int32_t pwm_duty_rb;
|
||||
uint32_t stop_have = 0;
|
||||
float qd_down = 0.0f;
|
||||
float last_gy = 0.0f;
|
||||
/*
|
||||
@@ -169,11 +168,7 @@ void sport_motion()
|
||||
cnt1++;
|
||||
cnt2++;
|
||||
cnt5++;
|
||||
// 屏蔽斑马线
|
||||
if (stop_have == 0) {
|
||||
stop_have = 1;
|
||||
by_frame_send(&stop_have);
|
||||
}
|
||||
|
||||
// pid参数切换
|
||||
if ((last_state != in_state) && (in_state == 0 || in_state == 2)) { // 直道
|
||||
cnt3_flag = 1;
|
||||
@@ -255,9 +250,9 @@ void sport_motion()
|
||||
cnt3 = 0;
|
||||
}
|
||||
if (in_speed > set_speed) {
|
||||
qd_down = 50;
|
||||
qd_down = 25;
|
||||
} else if (in_speed > set_speed - 100) {
|
||||
qd_down = 20;
|
||||
qd_down = 10;
|
||||
} else {
|
||||
qd_down = 0;
|
||||
}
|
||||
@@ -268,39 +263,29 @@ void sport_motion()
|
||||
cnt3_flag = 2;
|
||||
cnt3 = 0;
|
||||
}
|
||||
if (in_speed > set_speed) {
|
||||
qd_down = 4 * fabs(in_pos) + 20;
|
||||
} else if (in_speed > set_speed - 100) {
|
||||
qd_down = 2 * fabs(in_pos) + 10;
|
||||
} else {
|
||||
qd_down = 0;
|
||||
}
|
||||
} else if (in_state == 5) {
|
||||
if (cnt3 >= 400) // 200ms
|
||||
{
|
||||
bt_printf("to 开张");
|
||||
cnt3_flag = 2;
|
||||
cnt3 = 0;
|
||||
}
|
||||
if (in_speed > set_speed - 100) {
|
||||
qd_down = 150;
|
||||
} else if (in_speed > set_speed - 200) {
|
||||
qd_down = 75;
|
||||
} else {
|
||||
qd_down = 25;
|
||||
}
|
||||
if (in_speed > set_speed)
|
||||
qd_down = (in_speed - set_speed) * 0.5 + 40;
|
||||
else
|
||||
qd_down = -10;
|
||||
}
|
||||
|
||||
by_pwm_update_duty(bt_fly + 500 - qd_down, bt_fly + 500 - qd_down);
|
||||
} else {
|
||||
if (in_state == 1) {
|
||||
qd_down = 50;
|
||||
} else if (in_state == 3) {
|
||||
if (in_state == 1) { // 消除s弯降气垫
|
||||
if (in_speed >= set_speed / 1.2) {
|
||||
qd_down = 40;
|
||||
} else if (in_speed >= set_speed / 1.5) {
|
||||
qd_down = 25;
|
||||
} else if (in_speed >= set_speed / 2) {
|
||||
qd_down = 10;
|
||||
}else {
|
||||
qd_down = 0;
|
||||
}
|
||||
|
||||
} else {
|
||||
qd_down = 0;
|
||||
}
|
||||
|
||||
by_pwm_update_duty(bt_fly + 500 - qd_down, bt_fly + 500 - qd_down);
|
||||
}
|
||||
}
|
||||
@@ -327,7 +312,7 @@ void sport_pid_init()
|
||||
PID(&far_gyro_pid, &in_gyro, &out_gyro, &out_angle, gy_Kp1, gy_Ki1, gy_Kd1, _PID_P_ON_E, _PID_CD_REVERSE); // m是增量
|
||||
PID_SetMode(&far_gyro_pid, _PID_MODE_AUTOMATIC);
|
||||
PID_SetSampleTime(&far_gyro_pid, 20);
|
||||
PID_SetOutputLimits(&far_gyro_pid, -6000.0f, 6000.0f);
|
||||
PID_SetOutputLimits(&far_gyro_pid, -4800.0f, 4800.0f);
|
||||
|
||||
/* 速度控制 */
|
||||
PID(&speed_pid, &in_speed, &out_speed, &set_speed, sp_Kp, sp_Ki, sp_Kd, _PID_P_ON_M, _PID_CD_DIRECT);
|
||||
|
||||
@@ -37,13 +37,17 @@
|
||||
#include "by_rt_button.h"
|
||||
#include "by_fan_control.h"
|
||||
|
||||
uint32_t send_reset = 0x0D;
|
||||
int main(void)
|
||||
{
|
||||
TYPE_UNION test_data[BY_FRAME_DATA_NUM];
|
||||
clock_init(SYSTEM_CLOCK_144M);
|
||||
system_delay_init();
|
||||
debug_init();
|
||||
|
||||
by_frame_init();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
by_frame_send(&send_reset);
|
||||
}
|
||||
encoder_quad_init(TIM3_ENCOEDER, TIM3_ENCOEDER_MAP3_CH1_C6, TIM3_ENCOEDER_MAP3_CH2_C7);
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
while (imu660ra_init());
|
||||
@@ -52,7 +56,7 @@ int main(void)
|
||||
vol_init();
|
||||
by_rb_init();
|
||||
by_buzzer_init();
|
||||
by_frame_init();
|
||||
|
||||
by_pwm_init();
|
||||
|
||||
Page_Init();
|
||||
@@ -63,7 +67,6 @@ int main(void)
|
||||
bt_printf("ok\r\n");
|
||||
|
||||
while (1) {
|
||||
|
||||
// printf("pwm:%lu,%lu,%lu,%lu\r\n", pwm_duty_ls_g, pwm_duty_rs_g, pwm_duty_lb_g, pwm_duty_rb_g);
|
||||
Page_Run();
|
||||
by_frame_parse(&test_data[0].u32);
|
||||
|
||||
@@ -80,6 +80,11 @@ static void Event(page_event event)
|
||||
}
|
||||
} else if (page_event_press_long == event) {
|
||||
go_flag = 1;
|
||||
uint32_t temp = 0x5c;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
by_frame_send(&temp);
|
||||
}
|
||||
|
||||
ips200_clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user