diff --git a/01_Matlab/BLDCmotorControl_FOC_R2017b_fixdt.slx b/01_Matlab/BLDCmotorControl_FOC_R2017b_fixdt.slx index 7ae59db..9fa7c6d 100644 Binary files a/01_Matlab/BLDCmotorControl_FOC_R2017b_fixdt.slx and b/01_Matlab/BLDCmotorControl_FOC_R2017b_fixdt.slx differ diff --git a/01_Matlab/init_model.m b/01_Matlab/init_model.m index 4e3dce2..2e45e9c 100644 --- a/01_Matlab/init_model.m +++ b/01_Matlab/init_model.m @@ -58,16 +58,16 @@ r_cos_M1 = cos((a_elecAngle_XA + 30)*(pi/180)); %% Control Manager % Control type selection -CTRL_COM = 0; % [-] Commutation Control -CTRL_FOC = 1; % [-] Field Oriented Control (FOC) -z_ctrlTypSel = 1; % [-] Control Type Selection (default) +CTRL_COM = 0; % [-] Commutation Control +CTRL_FOC = 1; % [-] Field Oriented Control (FOC) +z_ctrlTypSel = CTRL_FOC; % [-] Control Type Selection (default) % Control model request -OPEN_MODE = 0; % [-] Open mode -VLT_MODE = 1; % [-] Voltage mode -SPD_MODE = 2; % [-] Speed mode -TRQ_MODE = 3; % [-] Torque mode -z_ctrlModReq = 1; % [-] Control Mode Request (default) +OPEN_MODE = 0; % [-] Open mode +VLT_MODE = 1; % [-] Voltage mode +SPD_MODE = 2; % [-] Speed mode +TRQ_MODE = 3; % [-] Torque mode +z_ctrlModReq = VLT_MODE; % [-] Control Mode Request (default) %% F01_Estimations % Position Estimation Parameters diff --git a/Inc/config.h b/Inc/config.h index 9d2eeb0..b6640d9 100644 --- a/Inc/config.h +++ b/Inc/config.h @@ -137,7 +137,7 @@ * 1. In BLDC_controller_data.c you can find the field weakening Map as a function of input target: MAP = id_fieldWeak_M1, XAXIS = r_fieldWeak_XA * 2. The default calibration was experimentally calibrated to my particular needs * 3. If you re-calibrate the field weakening map please take all the safety measures! The motors can spin very fast! - * 4. During the recalibration make sure the speed values in XAXIS are equally spaced for a correct Map interpolation. + * 4. During the recalibration make sure the values in XAXIS are equally spaced for a correct Map interpolation. */ @@ -152,7 +152,7 @@ */ // Value of FILTER is in fixdt(0,16,16) -// VAL_fixedPoint = VAL_floatingPoint * 2^16. In this case 6554 = 0.1 * 2^16 +// VAL_fixedPoint = VAL_floatingPoint * 2^16. In this case 6553 = 0.1 * 2^16 #define FILTER 6553 // 0.1f [-] lower value == softer filter [0, 65535] = [ 0.0 - 1.0]. // Value of COEFFICIENT is in fixdt(1,16,14) diff --git a/Src/bldc.c b/Src/bldc.c index c1e71c2..4a8d49f 100644 --- a/Src/bldc.c +++ b/Src/bldc.c @@ -79,10 +79,9 @@ static int16_t offsetdcr = 2000; int16_t batVoltage = (400 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE; static int16_t batVoltageFixdt = (400 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE << 4; // Fixed-point filter output initialized at 400 V*100/cell = 4 V/cell converted to fixed-point - -//scan 8 channels with 2ADCs @ 20 clk cycles per sample -//meaning ~80 ADC clock cycles @ 8MHz until new DMA interrupt =~ 100KHz -//=640 cpu cycles +// ================================= +// DMA interrupt frequency =~ 16 kHz +// ================================= void DMA1_Channel1_IRQHandler(void) { DMA1->IFCR = DMA_IFCR_CTCIF1;