Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 56:b050b80bab42, committed 2021-05-16
- Comitter:
- wyc136
- Date:
- Sun May 16 06:53:56 2021 +0000
- Parent:
- 55:489f01927025
- Commit message:
- motor config npp=21,GR=152
Changed in this revision
diff -r 489f01927025 -r b050b80bab42 CAN/CAN_com.h --- a/CAN/CAN_com.h Wed May 12 12:41:39 2021 +0000 +++ b/CAN/CAN_com.h Sun May 16 06:53:56 2021 +0000 @@ -17,9 +17,11 @@ #define V_MIN -15.0f #define V_MAX 15.0f #define KP_MIN 0.0f - #define KP_MAX 500.0f + #define KP_MAX 2000.0f + // #define KP_MAX 500.0f #define KD_MIN 0.0f - #define KD_MAX 5.0f + //#define KD_MAX 5.0f + #define KD_MAX 200.0f // #define T_MIN -18.0f //#define T_MAX 18.0f #define T_MIN -50.0f
diff -r 489f01927025 -r b050b80bab42 Calibration/calibration.cpp --- a/Calibration/calibration.cpp Wed May 12 12:41:39 2021 +0000 +++ b/Calibration/calibration.cpp Sun May 16 06:53:56 2021 +0000 @@ -18,7 +18,7 @@ float theta_actual = 0; //float v_d = .15f; //float v_d = .20f; - float v_d = .40f; //Put all volts on the D-Axis + float v_d = .10f; //Put all volts on the D-Axis float v_q = 0.0f; float v_u, v_v, v_w = 0; float dtc_u, dtc_v, dtc_w = .5f; @@ -92,7 +92,7 @@ float theta_actual = 0; //float v_d = .15f; // float v_d = .20f; - float v_d = .40f; // Put volts on the D-Axis + float v_d = .10f; // Put volts on the D-Axis float v_q = 0.0f; float v_u, v_v, v_w = 0; float dtc_u, dtc_v, dtc_w = .5f; @@ -497,7 +497,7 @@ //float v_d = .15f; //float v_d = .18f; - float v_d = .60f; // Put volts on the D-Axis + float v_d = .10f; // Put volts on the D-Axis float v_q = 0.0f; float v_u, v_v, v_w = 0; float dtc_u, dtc_v, dtc_w = .5f; @@ -582,12 +582,14 @@ theta_joint_actual = jps->GetMechPositionFixed(); //error_joint_b[i] = theta_joint_ref*(1+1/GR)/NPP - theta_joint_actual; - error_joint_b[i] = (theta_joint_ref-(1/GR)*theta_ref)/NPP -theta_joint_actual; + // error_joint_b[i] = (theta_joint_ref-(1/GR)*theta_ref)/NPP -theta_joint_actual; + error_joint_b[i] = (theta_joint_ref+(1/GR)*theta_ref)/NPP -theta_joint_actual; //hjb 202105 joint_raw_b[i] = jps->GetRawPosition();//-raw_b[i]/GR; //printf("%.4f %.4f %d-\n\r", theta_ref*(1+1/GR)/(NPP), theta_joint_actual, joint_raw_b[i]); - printf("%.4f %.4f %d\n\r", (theta_joint_ref-(1/GR)*theta_ref)/NPP, theta_joint_actual, joint_raw_b[i]); + // printf("%.4f %.4f %d\n\r", (theta_joint_ref-(1/GR)*theta_ref)/NPP, theta_joint_actual, joint_raw_b[i]); + printf("%.4f %.4f %d\n\r", (theta_joint_ref+(1/GR)*theta_ref)/NPP, theta_joint_actual, joint_raw_b[i]);//Hjb 202105 //theta_ref -= delta; }
diff -r 489f01927025 -r b050b80bab42 Config/motor_config.h --- a/Config/motor_config.h Wed May 12 12:41:39 2021 +0000 +++ b/Config/motor_config.h Sun May 16 06:53:56 2021 +0000 @@ -13,7 +13,7 @@ #define KT .08f//.075f //N-m per peak phase amp, = WB*NPP*3/2 #define NPP 21 //Number of pole pairs //#define GR 1.0f //Gear ratio -#define GR 49.0f //Gear ratio +#define GR 151.0f //Gear ratio #define KT_OUT 7.12//3.92f//0.45f //KT*GR #define WB 0.00287f //Webers. #define R_TH 1.25f //Kelvin per watt
diff -r 489f01927025 -r b050b80bab42 main.cpp --- a/main.cpp Wed May 12 12:41:39 2021 +0000 +++ b/main.cpp Sun May 16 06:53:56 2021 +0000 @@ -10,7 +10,7 @@ #define ENCODER_MODE 5 #define TEST_TRAJECTORY_MODE 6 #define J_CALIBRATION_MODE 7 -#define VERSION_NUM "1.6" +#define VERSION_NUM "2.1_RV_50Nm" float __float_reg[64]; // Floats stored in flash @@ -57,7 +57,7 @@ PositionSensorAM5147 spi(16384, 0.0, NPP); //14 bits encoder, 21 NPP PositionSensorMA700 ma700(16384,0.0,NPP); //shaorui add(12/10) -volatile int count = 0; +volatile int count1 = 0; volatile int state = REST_MODE; volatile int state_change; volatile float Joint_init =0; //Joint intial angle @@ -221,7 +221,6 @@ state=MOTOR_MODE; state_change=1; //enter_torque_mode(); - count = 0; printf("test\n\r"); controller.p_des=0; controller.v_des = 1.5f; @@ -291,7 +290,7 @@ controller.dtheta_elec1 = ma700.GetElecVelocity(); ///hjb add joint angle - controller.theta_joint_raw= -(ma700.GetMechPosition()+spi.GetMechPosition()); + controller.theta_joint_raw= (ma700.GetMechPosition()+spi.GetMechPosition());//the direction of spi.get turn '-' when using RV //if(controller.dtheta_mech>0) {controller.theta_joint_raw += PI/180.0f;} //compensate // else if(controller.dtheta_mech<0) {controller.theta_joint_raw -= PI/180.0f;} if(controller.theta_joint_raw<0){controller.theta_joint_raw += 2.0f*PI;} @@ -387,7 +386,7 @@ case MOTOR_MODE: // Run torque control if(state_change){ enter_torque_mode(); - count = 0; + count1 = 0; } else{ /* @@ -399,7 +398,7 @@ printf("OVP Triggered!\n\r"); } */ - + count1++; torque_control(&controller); if((controller.timeout > CAN_TIMEOUT) && (CAN_TIMEOUT > 0)){ @@ -414,11 +413,11 @@ controller.timeout += 1; - count++; + /* - if(count == 4000){ + if(count1 == 4000){ printf("%.4f\n\r", controller.dtheta_mech); - count = 0; + count1 = 0; } */ @@ -692,13 +691,13 @@ printf("test position:%.3f\n\r",(1.0f/GR)* spi.GetMechPosition()); } - + //printf("test position:real mebh SPI %.3f OUT %.3f\n\r",(1.0f/GR)* spi.GetMechPosition(),ma700.GetMechPosition());//wyc 2021.05.14 - if(count >= 40000){ - printf("J_init: %.3f Pref: %.3f preal: %.3f JM: %.3d one: %.3f two: %.3f\n\r",Joint_init*57.2957795,(1.0f/GR)*spi.GetMechPosition()*57.2957795,controller.theta_mech*57.2957795,J_M_flag ,controller.Ncycle_mod*57.2957795-controller.Mech_mod*57.2957795/GR,(controller.theta_joint- controller.theta_joint_raw)*57.2957795); - // printf("Pref: %.3f qian: %.3f hou: %.3f M: %.3d \n\r", (1.0f/GR)*spi.GetMechPosition()*57.2957795,controller.theta_joint_raw*57.2957795,controller.theta_mech*57.2957795,J_M_flag); + if(count1 >= 40000){ + // printf("J_init: %.3f Pref: %.3f preal: %.3f JM: %.3d one: %.3f two: %.3f\n\r",Joint_init*57.2957795,(1.0f/GR)*spi.GetMechPosition()*57.2957795,controller.theta_mech*57.2957795,J_M_flag ,controller.Ncycle_mod*57.2957795-controller.Mech_mod*57.2957795/GR,(controller.theta_joint- controller.theta_joint_raw)*57.2957795); + printf("Pref: %.3f qian: %.3f hou: %.3f M: %.3d \n\r", (1.0f/GR)*spi.GetMechPosition()*57.2957795,controller.theta_joint_raw*57.2957795,controller.theta_mech*57.2957795,J_M_flag); // printf("v: %.3f v1: %.3f \n\r",controller.dtheta_mech*57.2957795,controller.dtheta_mech1*57.2957795); - count = 0; + count1 = 0; } i++;
diff -r 489f01927025 -r b050b80bab42 mbed-dev.lib --- a/mbed-dev.lib Wed May 12 12:41:39 2021 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://os.mbed.com/users/benkatz/code/mbed-dev-f303/#36facd806e4a
diff -r 489f01927025 -r b050b80bab42 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun May 16 06:53:56 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file