1
Dependencies: mbed-dev-f303 FastPWM3
Diff: Calibration/calibration.cpp
- Revision:
- 49:7eac11914980
- Parent:
- 48:1b51771c3647
- Child:
- 51:29e1686e8b3e
--- a/Calibration/calibration.cpp Fri Feb 07 11:31:37 2020 +0000 +++ b/Calibration/calibration.cpp Thu Mar 19 03:48:24 2020 +0000 @@ -17,7 +17,7 @@ float theta_ref = 0; float theta_actual = 0; //float v_d = .15f; - float v_d = .23f; //Put all volts on the D-Axis + float v_d = .15f; //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; @@ -63,7 +63,7 @@ theta_ref += 0.001f; } float theta_end = ps->GetMechPositionFixed(); - int direction = (theta_end - theta_start)>0; + int direction = 1;//(theta_end - theta_start)>0; printf("Theta Start: %f Theta End: %f\n\r", theta_start, theta_end); printf("Direction: %d\n\r", direction); if(direction){printf("Phasing correct\n\r");} @@ -90,7 +90,7 @@ float theta_ref = 0; float theta_actual = 0; //float v_d = .15f; - float v_d = .2f; // Put volts on the D-Axis + float v_d = .15f; // 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; @@ -139,7 +139,9 @@ theta_actual = ps->GetMechPositionFixed(); error_f[i] = theta_ref/NPP - theta_actual; raw_f[i] = ps->GetRawPosition(); - printf("ref %.4f\n\r actual %.4f\n\r raw %d\n\r", theta_ref/(NPP), theta_actual, raw_f[i]); + printf("%.4f %.4f %d\n\r", theta_ref/(NPP), theta_actual, raw_f[i]); + + // printf("ref %.4f\n\r actual %.4f\n\r raw %d\n\r", theta_ref/(NPP), theta_actual, raw_f[i]); //theta_ref += delta; } @@ -164,7 +166,9 @@ theta_actual = ps->GetMechPositionFixed(); // get mechanical position error_b[i] = theta_ref/NPP - theta_actual; raw_b[i] = ps->GetRawPosition(); - printf("ref %.4f\n\r actual %.4f\n\r raw %d\n\r", theta_ref/(NPP), theta_actual, raw_b[i]); + printf("%.4f %.4f %d\n\r", theta_ref/(NPP), theta_actual, raw_b[i]); + + //printf("ref %.4f\n\r actual %.4f\n\r raw %d\n\r", theta_ref/(NPP), theta_actual, raw_b[i]); //theta_ref -= delta; } @@ -480,7 +484,7 @@ jps->WriteLUT(joint); - jps->ReadLUT(); +// jps->ReadLUT(); int joint_raw_f[n] = {0}; int joint_raw_b[n] = {0}; @@ -490,11 +494,11 @@ float theta_joint_actual = 0; //float v_d = .15f; - float v_d = .2f; // Put volts on the D-Axis + float v_d = .18f; // 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; - + PHASE_ORDER =1; //!!!hjb added, direction always run error, so pre to 1 in hardware UVW. ///Set voltage angle to zero, wait for rotor position to settle abc(theta_ref, v_d, v_q, &v_u, &v_v, &v_w); // inverse dq0 transform on voltages @@ -546,7 +550,7 @@ joint_raw_f[i] = jps->GetRawPosition(); //printf("%.4f %.4f %d\n\r", theta_joint_ref*(1+1/GR)/(NPP), theta_joint_actual, joint_raw_f[i]); - printf("ref %.4f\n\r actual %.4f\n\r raw %d\n\r", (theta_joint_ref-(1/GR)*theta_ref)/NPP, theta_joint_actual, joint_raw_f[i]); + printf("%.4f %.4f %d\n\r", (theta_joint_ref-(1/GR)*theta_ref)/NPP, theta_joint_actual, joint_raw_f[i]); //theta_ref += delta; } @@ -580,7 +584,7 @@ //printf("%.4f %.4f %d-\n\r", theta_ref*(1+1/GR)/(NPP), theta_joint_actual, joint_raw_b[i]); - printf("ref %.4f\n\r actual %.4f\n\r raw %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]); //theta_ref -= delta; }