初定版本
Dependencies: mbed Hobbyking_Cheetah FastPWM3
Diff: CAN/CAN_com.cpp
- Revision:
- 55:d57335792cb7
- Parent:
- 54:59575833d16f
diff -r 59575833d16f -r d57335792cb7 CAN/CAN_com.cpp --- a/CAN/CAN_com.cpp Thu Aug 08 17:39:43 2019 +0000 +++ b/CAN/CAN_com.cpp Tue May 10 02:10:43 2022 +0000 @@ -12,6 +12,20 @@ #define T_MIN -18.0f #define T_MAX 18.0f + /* + //为保证设置参数的最小分辨率,可启用下列参数 + //注意:必须保证上、下转换时,MIN/MAX的一致,否则数据会出错!!! + #define P_MIN -150f + #define P_MAX 150f + #define V_MIN -270.0f + #define V_MAX 270.0f + #define KP_MIN 0.0f + #define KP_MAX 50.0f + #define KD_MIN 0.0f + #define KD_MAX 5.0f + #define T_MIN -5.0f + #define T_MAX 5.0f + */ /// CAN Reply Packet Structure /// /// 16 bit position, between -4*pi and 4*pi @@ -61,9 +75,13 @@ controller->p_des = uint_to_float(p_int, P_MIN, P_MAX, 16); controller->v_des = uint_to_float(v_int, V_MIN, V_MAX, 12); - controller->kp = uint_to_float(kp_int, KP_MIN, KP_MAX, 12); + controller->v_des /= GR; // plan A&B&C, modify by 20210630 + controller->kp = uint_to_float(kp_int, KP_MIN, KP_MAX, 12); + controller->kp *= GR; // plan A&B&C, modify by 20210630 controller->kd = uint_to_float(kd_int, KD_MIN, KD_MAX, 12); + //controller->kd /= GR; // plan B&C, modify by 20210630 controller->t_ff = uint_to_float(t_int, T_MIN, T_MAX, 12); + controller->t_ff *= GR; // plan A&C, modify by 20210630 //printf("Received "); //printf("%.3f %.3f %.3f %.3f %.3f %.3f", controller->p_des, controller->v_des, controller->kp, controller->kd, controller->t_ff, controller->i_q_ref); //printf("\n\r");