1
Dependencies: mbed-dev-f303 FastPWM3
Diff: CAN/CAN_com.cpp
- Revision:
- 52:91a42bd0fe2e
- Parent:
- 51:b0a3ef66ea3d
- Child:
- 54:b8c3cfff4841
--- a/CAN/CAN_com.cpp Wed May 08 01:17:38 2019 +0000 +++ b/CAN/CAN_com.cpp Wed May 08 05:36:07 2019 +0000 @@ -3,10 +3,13 @@ #define P_MIN -12.5f #define P_MAX 12.5f - #define V_MIN -45.0f - #define V_MAX 45.0f + //#define V_MIN -45.0f + //#define V_MAX 45.0f + #define V_MIN -314.0f + #define V_MAX 314.0f #define KP_MIN 0.0f - #define KP_MAX 500.0f +// #define KP_MAX 500.0f + #define KP_MAX 0.05f #define KD_MIN 0.0f #define KD_MAX 5.0f #define T_MIN -18.0f @@ -53,18 +56,18 @@ /// 6: [kd[3-0], torque[11-8]] /// 7: [torque[7-0]] void unpack_cmd(CANMessage msg, ControllerStruct * controller){ - int p_int = (msg.data[0]<<8)|msg.data[1]; - // int v_int = (msg.data[2]<<4)|(msg.data[3]>>4); //==========HJB delete========== - int Tper_int = (msg.data[2]<<4)|(msg.data[3]>>4); + int p_int = (msg.data[0]<<8)|msg.data[1]; + int v_int = (msg.data[2]<<4)|(msg.data[3]>>4); //==========HJB delete========== + // int Tper_int = (msg.data[2]<<4)|(msg.data[3]>>4); int kp_int = ((msg.data[3]&0xF)<<8)|msg.data[4]; int kd_int = (msg.data[5]<<4)|(msg.data[6]>>4); int t_int = ((msg.data[6]&0xF)<<8)|msg.data[7]; - //controller->p_des = uint_to_float(p_int, P_MIN, P_MAX, 16); //==========HJB delete========== - //controller->v_des = uint_to_float(v_int, V_MIN, V_MAX, 12); + controller->p_des = uint_to_float(p_int, P_MIN, P_MAX, 16); //==========HJB delete========== + controller->v_des = uint_to_float(v_int, V_MIN, V_MAX, 12); //===================HJB added for inner trajectory Pmag and Tperiod input =========================// - controller->PmagIn = uint_to_float(p_int, 1, P_MAX, 16); //==========Pmag span form 1 to 4PI========== - controller->TperiodIn = uint_to_float(Tper_int, 1, 100, 12); //Time period span from 1 to 100s; + //controller->PmagIn = uint_to_float(p_int, 1, P_MAX, 16); //==========Pmag span form 1 to 4PI========== + //controller->TperiodIn = uint_to_float(Tper_int, 1, 100, 12); //Time period span from 1 to 100s; //===================HJB ended for inner trajectory Pmag and Tperiod input =========================// controller->kp = uint_to_float(kp_int, KP_MIN, KP_MAX, 12); controller->kd = uint_to_float(kd_int, KD_MIN, KD_MAX, 12);