BLDC motor driver
Dependencies: mbed-dev-f303 FastPWM3
Diff: Calibration/calibration.cpp
- Revision:
- 38:67e4e1453a4b
- Parent:
- 28:8c7e29f719c5
- Child:
- 44:8040fa2fcb0d
--- a/Calibration/calibration.cpp Fri Apr 13 13:50:54 2018 +0000 +++ b/Calibration/calibration.cpp Mon May 14 20:59:02 2018 +0000 @@ -32,7 +32,7 @@ //ps->ZeroPosition(); ps->Sample(); wait_us(1000); - //float theta_start = ps->GetMechPosition(); //get initial rotor position + //float theta_start = ps->GetMechPositionFixed(); //get initial rotor position float theta_start; controller->i_b = I_SCALE*(float)(controller->adc2_raw - controller->adc2_offset); //Calculate phase currents from ADC readings controller->i_c = I_SCALE*(float)(controller->adc1_raw - controller->adc1_offset); @@ -50,7 +50,7 @@ TIM1->CCR2 = (PWM_ARR>>1)*(1.0f-dtc_v); TIM1->CCR1 = (PWM_ARR>>1)*(1.0f-dtc_w); ps->Sample(); //sample position sensor - theta_actual = ps->GetMechPosition(); + theta_actual = ps->GetMechPositionFixed(); if(theta_ref==0){theta_start = theta_actual;} if(sample_counter > 200){ sample_counter = 0 ; @@ -59,7 +59,7 @@ sample_counter++; theta_ref += 0.001f; } - float theta_end = ps->GetMechPosition(); + float theta_end = ps->GetMechPositionFixed(); int direction = (theta_end - theta_start)>0; printf("Theta Start: %f Theta End: %f\n\r", theta_start, theta_end); printf("Direction: %d\n\r", direction); @@ -132,7 +132,7 @@ ps->Sample(); } ps->Sample(); - theta_actual = ps->GetMechPosition(); + theta_actual = ps->GetMechPositionFixed(); error_f[i] = theta_ref/NPP - theta_actual; raw_f[i] = ps->GetRawPosition(); printf("%.4f %.4f %d\n\r", theta_ref/(NPP), theta_actual, raw_f[i]); @@ -157,7 +157,7 @@ ps->Sample(); } ps->Sample(); // sample position sensor - theta_actual = ps->GetMechPosition(); // get mechanical position + theta_actual = ps->GetMechPositionFixed(); // get mechanical position error_b[i] = theta_ref/NPP - theta_actual; raw_b[i] = ps->GetRawPosition(); printf("%.4f %.4f %d\n\r", theta_ref/(NPP), theta_actual, raw_b[i]);