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.
Diff: Calibration/calibration.cpp
- Revision:
- 45:aadebe074af6
- Parent:
- 44:efcde0af8390
- Child:
- 49:9d762c5d05c3
--- a/Calibration/calibration.cpp Sat Jul 14 22:03:52 2018 +0000
+++ b/Calibration/calibration.cpp Mon Jul 30 20:25:24 2018 +0000
@@ -32,7 +32,7 @@
wait_us(100);
}
//ps->ZeroPosition();
- ps->Sample();
+ ps->Sample(DT);
wait_us(1000);
//float theta_start = ps->GetMechPositionFixed(); //get initial rotor position
float theta_start;
@@ -51,7 +51,7 @@
TIM1->CCR3 = (PWM_ARR>>1)*(1.0f-dtc_u); //Set duty cycles
TIM1->CCR2 = (PWM_ARR>>1)*(1.0f-dtc_v);
TIM1->CCR1 = (PWM_ARR>>1)*(1.0f-dtc_w);
- ps->Sample(); //sample position sensor
+ ps->Sample(DT); //sample position sensor
theta_actual = ps->GetMechPositionFixed();
if(theta_ref==0){theta_start = theta_actual;}
if(sample_counter > 200){
@@ -109,7 +109,7 @@
}
wait_us(100);
}
- ps->Sample();
+ ps->Sample(DT);
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);
controller->i_a = -controller->i_b - controller->i_c;
@@ -131,9 +131,9 @@
TIM1->CCR2 = (PWM_ARR>>1)*(1.0f-dtc_w);
}
wait_us(100);
- ps->Sample();
+ ps->Sample(DT);
}
- ps->Sample();
+ ps->Sample(DT);
theta_actual = ps->GetMechPositionFixed();
error_f[i] = theta_ref/NPP - theta_actual;
raw_f[i] = ps->GetRawPosition();
@@ -156,9 +156,9 @@
TIM1->CCR2 = (PWM_ARR>>1)*(1.0f-dtc_w);
}
wait_us(100);
- ps->Sample();
+ ps->Sample(DT);
}
- ps->Sample(); // sample position sensor
+ ps->Sample(DT); // sample position sensor
theta_actual = ps->GetMechPositionFixed(); // get mechanical position
error_b[i] = theta_ref/NPP - theta_actual;
raw_b[i] = ps->GetRawPosition();