Merge branch 'master' of http://172.30.0.1:8418/cbb/Robot_v2
This commit is contained in:
+7
-45
@@ -1,6 +1,5 @@
|
||||
#ifndef __CONFIG_H
|
||||
#define __CONFIG_H
|
||||
#include "gd32c10x_eval.h"
|
||||
#include <cstdint>
|
||||
|
||||
// 如果使用CMSIS DSP库,需要定义ARM_MATH_CM4
|
||||
@@ -88,50 +87,17 @@ constexpr float CURRENT_KALMAN_PROCESS_NOISE_Q = 10.0f; // 降低过程噪声
|
||||
constexpr float CURRENT_KALMAN_MEASUREMENT_NOISE_R = 5e-5f; // 增大测量噪声
|
||||
|
||||
// PID配置
|
||||
constexpr float DEFAULT_current_loop_p = 0.1f / 100 * 12; // 电流P
|
||||
constexpr float current_loop_Ki = 0.55f; // 电流P
|
||||
constexpr float current_loop_Kd = 3e-4f; // 电流P
|
||||
|
||||
constexpr float DEFAULT_vel_loop_p = 0.018f / 100 * 12; // 速度P
|
||||
constexpr float vel_loop_Ku = 3.600000e-03 * 0.7 * 100 / 12;
|
||||
constexpr float vel_loop_Tu = 17.0f * 1e-3f;
|
||||
constexpr float vel_loop_Ki = 1.2 * vel_loop_Ku / vel_loop_Tu;
|
||||
constexpr float vel_loop_Kd = 0.075 * vel_loop_Ku * vel_loop_Tu * 2;
|
||||
|
||||
constexpr float DEFAULT_vel_angloop_p = 0.4f / 100; // 速度 速度-角度P
|
||||
constexpr float vel_angloop_Ki = 5.0f; // 速度 速度-角度I
|
||||
constexpr float vel_angloop_Kd = 5e-05f; // 速度 速度-角度D
|
||||
|
||||
constexpr float DEFAULT_angle_angloop_p = 150.0f / 100 * 12; // 角度 速度-角度P
|
||||
constexpr float ang_angloop_Ki = 0.00f; // 角度 速度-角度I
|
||||
constexpr float ang_angloop_Kd = 8e-04f; // 角度 速度-角度D
|
||||
|
||||
constexpr float DEFAULT_angle_loop_p = 60.0f / 100 * 12; // 角度P
|
||||
|
||||
constexpr float DEFAULT_angle_MIT_p = 100.0f / 100 * 12; // 角度 MIT P
|
||||
constexpr float angle_MIT_Ki = 0.0f;
|
||||
constexpr float angle_MIT_Kd = 8e-04f;
|
||||
|
||||
constexpr float DEFAULT_vel_MIT_p = 5.0f / 100; // 速度 MIT P
|
||||
constexpr float vel_MIT_Ki = 15.0f;
|
||||
constexpr float vel_MIT_Kd = 1e-04f;
|
||||
|
||||
constexpr float DEFAULT_current_MIT_p = 0.2f / 100 * 12; // 电流 MIT P
|
||||
constexpr float current_MIT_Ki = 0.1f;
|
||||
constexpr float current_MIT_Kd = 3e-4f;
|
||||
constexpr float current_loop_p = 6e-2f / 100 * 12; // 电流P
|
||||
constexpr float vel_loop_p = 0.01f / 100 * 12; // 速度P
|
||||
constexpr float angle_loop_p = 20.0f / 100 * 12; // 角度P
|
||||
constexpr float vel_angloop_p = 0.12f / 100 * 12; // 速度 速度-角度P
|
||||
constexpr float ang_angloop_p = 100.0f / 100 * 12; // 角度 速度-角度P
|
||||
|
||||
// 常量定义
|
||||
constexpr u8 SIZE_FLOAT = sizeof(float);
|
||||
constexpr u8 SIZE_U32 = sizeof(uint32_t);
|
||||
constexpr float ADC_MAX = 65536.0f;
|
||||
constexpr float PI = 3.14159265358979323846f;
|
||||
constexpr float INV_PI_3 = 3.0f / PI;
|
||||
constexpr float PI_3 = PI / 3.0f;
|
||||
constexpr float _1_SQRT3 = 0.57735026919f; // 1/sqrt(3)
|
||||
constexpr float _3PI_2 = 4.71238898038f;
|
||||
constexpr float SQRT3 = 1.7320508075688772f;
|
||||
constexpr float SQRT3DV2 = 0.8660254037844386f; // sqrt(3)/2
|
||||
constexpr float COS_PI_3 = 0.5f;
|
||||
constexpr float ANGLE_FACTOR = 25.0f / 180.0f * PI;
|
||||
constexpr float DEG2RAD = 1.0f / 180.0f * PI;
|
||||
constexpr float RAD2DEG = 180.0f / PI; // 修正RAD2DEG定义,应该是180/π
|
||||
@@ -183,12 +149,8 @@ constexpr float ANGLESENS_FACTOR = 1.0f / ADC_MAX * 360.0f;
|
||||
|
||||
// TIMER2-任务调度
|
||||
constexpr int TIMER2_PRESCALER = 119; // 120MHz / 120 = 1MHz
|
||||
constexpr int TIMER2_PERIOD = 49; // 1 / 1MHz * 50 = 50us
|
||||
constexpr int MOTOR_PERIOD = 2; // 100us/50us = 2
|
||||
constexpr float TIME_SLICE =
|
||||
(TIMER2_PERIOD + 1) * (TIMER2_PRESCALER + 1) / 120000000.0f; // 周期
|
||||
constexpr float TIMER2_FREQUENCY = 1 / TIME_SLICE; // 频率
|
||||
constexpr float MOTOR_FREQUENCY = 1 / TIME_SLICE / MOTOR_PERIOD; // 频率
|
||||
constexpr int TIMER2_PERIOD = 49; // 1MHz / 50 = 50us
|
||||
constexpr float TIMER2_FREQUENCY = 1 / 5e-5;
|
||||
|
||||
// TIMER1-PWM
|
||||
constexpr int TIMER1_PRESCALER = 0; // 不分频,计数器时钟为120MHz
|
||||
|
||||
Reference in New Issue
Block a user