|
|
@@ -32,15 +32,15 @@ clear
|
|
|
clc
|
|
|
|
|
|
% Load model parameters
|
|
|
-Ts = 6.2e-6; % [s] Model sampling time (1 MHz)
|
|
|
-Ts_ctrl = 62e-6; % [s] Controller sampling time (~16 kHz)
|
|
|
-f_ctrl = 16e3; % [Hz] Controller frequency = 1/Ts_ctrl (16 kHz)
|
|
|
+Ts = 5e-6; % [s] Model sampling time (1 MHz)
|
|
|
+f_ctrl = 20e3; % [Hz] Controller frequency = 1/Ts_ctrl (16 kHz)
|
|
|
+Ts_ctrl = 1/f_ctrl; % [s] Controller sampling time (~16 kHz)
|
|
|
Ts_speed = Ts_ctrl * 50;
|
|
|
-i_pwm_count = 4000;
|
|
|
+i_pwm_count = f_ctrl/4;
|
|
|
i_dead = 10;
|
|
|
i_adc = 10;
|
|
|
i_sample_before = 10;
|
|
|
-i_Udc = 300;
|
|
|
+i_Udc = 48;
|
|
|
i_half_pwm_count = i_pwm_count;
|
|
|
i_sample_min = (i_dead + i_adc + i_sample_before);
|
|
|
i_hall_count_max = 1/Ts;
|
|
|
@@ -74,7 +74,7 @@ n_max = 5000; % [rpm] Maximum motor speed: [-5000, 500
|
|
|
% open loop speed -> voltage lookup table
|
|
|
res_rpm_openloop = 100;
|
|
|
delta_rpm_openloop = 100; % delta rpm that when speed decreased, enter open loop
|
|
|
-min_start_voltage_openloop = 100;
|
|
|
+min_start_voltage_openloop = 10;
|
|
|
a_rpm_step = i_Udc / (n_max / res_rpm_openloop);
|
|
|
% Motor parameters
|
|
|
n_polePairs = 4; % [-] Number of motor pole pairs
|
|
|
@@ -83,11 +83,11 @@ a_elecDeltaAngle = 60; % [deg] Electrical angl
|
|
|
a_mechAngle = a_elecDeltaAngle / n_polePairs; % [deg] Mechanical angle between two Hall sensor changing events
|
|
|
r_whl = 6.5 * 2.54 * 1e-2 / 2; % [m] Wheel radius. Diameter = 6.5 inch (1 inch = 2.54 cm): Speed[kph] = rpm*(pi/30)*r_whl*3.6
|
|
|
|
|
|
-f_lpf_coeff = 0.12;
|
|
|
+f_lpf_coeff = 0.4;
|
|
|
|
|
|
%hall, [4,6,2,3,1,5,4] [ 3,2,6,4,5,1]
|
|
|
vec_hallToPos = [7 5 1 0 3 4 2 7]; % [-] Mapping Hall signal to position
|
|
|
-i_hall_offset = -30;
|
|
|
+i_hall_offset = 60;%-30;
|
|
|
|
|
|
% Speed Calculation Parameters
|
|
|
cf_speedCoef = (i_hall_count_max * a_mechAngle * (pi/180) * (30/pi)); % [-] Speed calculation coefficient (factors are due to conversions rpm <-> rad/s)
|
|
|
@@ -132,14 +132,13 @@ cf_nKiLimProt = 20 / (f_ctrl/3); % [-] Speed limit protection integral ga
|
|
|
cf_KbLimProt = 1000 / (f_ctrl/3);% [-] Back calculation gain for integral anti-windup
|
|
|
|
|
|
% Voltage Limitations
|
|
|
-V_margin = 0.95; % [-] Voltage margin to make sure that there is a sufficiently wide pulse for a good phase current measurement
|
|
|
-Vd_max = i_Udc * V_margin;
|
|
|
+V_modulation = 0.95; % [-] Voltage margin to make sure that there is a sufficiently wide pulse for a good phase current measurement
|
|
|
+Vd_max = i_Udc * V_modulation;
|
|
|
Vq_max_XA = 0:1:Vd_max;
|
|
|
Vq_max_M1 = sqrt(Vd_max^2 - Vq_max_XA.^2); % Circle limitations look-up table
|
|
|
-
|
|
|
i_sca = 1; % [-] [not tunable] Scalling factor A to int16 (50 = 1/0.02)
|
|
|
% Current Limitations
|
|
|
-i_max = 45; % [A] Maximum allowed motor current (continuous)
|
|
|
+i_max = 120; % [A] Maximum allowed motor current (continuous)
|
|
|
i_max = i_max * i_sca;
|
|
|
iq_maxSca_XA = 0:0.02:0.99;
|
|
|
iq_maxSca_XA = fixpt_evenspace_cleanup(iq_maxSca_XA, ufix(16), 2^-16); % Make sure the data is evely spaced up to the last bit
|