Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted PWM switching frequency to match the setting #397

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1698,15 +1698,15 @@ void commands_apply_mcconf_hw_limits(mc_configuration *mcconf) {
#ifdef HW_LIM_FOC_CTRL_LOOP_FREQ
if (mcconf->foc_sample_v0_v7 == true) {
//control loop executes twice per pwm cycle when sampling in v0 and v7
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ);
ctrl_loop_freq = mcconf->foc_f_sw;
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ / 2.0);
ctrl_loop_freq = mcconf->foc_f_sw * 2.0;
} else {
#ifdef HW_HAS_DUAL_MOTORS
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ);
ctrl_loop_freq = mcconf->foc_f_sw;
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ / 2.0);
ctrl_loop_freq = mcconf->foc_f_sw * 2.0;
#else
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ * 2.0);
ctrl_loop_freq = mcconf->foc_f_sw / 2.0;
utils_truncate_number(&mcconf->foc_f_sw, HW_LIM_FOC_CTRL_LOOP_FREQ);
ctrl_loop_freq = mcconf->foc_f_sw;
#endif
}
#endif
Expand Down Expand Up @@ -1976,7 +1976,7 @@ static THD_FUNCTION(blocking_thread, arg) {
float current = buffer_get_float32(data, 1e3, &ind);

mcconf->motor_type = MOTOR_TYPE_FOC;
mcconf->foc_f_sw = 10000.0;
mcconf->foc_f_sw = 5000.0;
mcconf->foc_current_kp = 0.01;
mcconf->foc_current_ki = 10.0;
mc_interface_set_configuration(mcconf);
Expand Down Expand Up @@ -2024,7 +2024,7 @@ static THD_FUNCTION(blocking_thread, arg) {
float current = buffer_get_float32(data, 1e3, &ind);

mcconf->motor_type = MOTOR_TYPE_FOC;
mcconf->foc_f_sw = 10000.0;
mcconf->foc_f_sw = 5000.0;
mcconf->foc_current_kp = 0.01;
mcconf->foc_current_ki = 10.0;
mc_interface_set_configuration(mcconf);
Expand Down
8 changes: 4 additions & 4 deletions conf_general.c
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss,

mcconf->motor_type = MOTOR_TYPE_FOC;
mcconf->foc_sensor_mode = FOC_SENSOR_MODE_SENSORLESS;
mcconf->foc_f_sw = 10000.0; // Lower f_sw => less dead-time distortion
mcconf->foc_f_sw = 5000.0; // Lower f_sw => less dead-time distortion
mcconf->foc_current_kp = 0.0005;
mcconf->foc_current_ki = 1.0;
mcconf->l_current_max = MCCONF_L_CURRENT_MAX;
Expand All @@ -1532,7 +1532,7 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
#ifdef HW_HAS_DUAL_MOTORS
mcconf_second->motor_type = MOTOR_TYPE_FOC;
mcconf_second->foc_sensor_mode = FOC_SENSOR_MODE_SENSORLESS;
mcconf_second->foc_f_sw = 10000.0; // Lower f_sw => less dead-time distortion
mcconf_second->foc_f_sw = 5000.0; // Lower f_sw => less dead-time distortion
mcconf_second->foc_current_kp = 0.0005;
mcconf_second->foc_current_ki = 1.0;
mcconf_second->l_current_max = MCCONF_L_CURRENT_MAX;
Expand Down Expand Up @@ -1629,12 +1629,12 @@ int conf_general_detect_apply_all_foc(float max_power_loss,
// Increase switching frequency for flux linkage measurement
// as dead-time distortion has less effect at higher modulation.
// Having a smooth rotation is more important.
mcconf->foc_f_sw = 20000.0;
mcconf->foc_f_sw = 10000.0;
mc_interface_set_configuration(mcconf);

#ifdef HW_HAS_DUAL_MOTORS
mc_interface_select_motor_thread(2);
mcconf_second->foc_f_sw = 20000.0;
mcconf_second->foc_f_sw = 10000.0;
mc_interface_set_configuration(mcconf_second);
mc_interface_select_motor_thread(1);
#endif
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_100_250.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_L_MAX_ABS_CURRENT
#define MCCONF_L_MAX_ABS_CURRENT 400.0 // The maximum absolute current above which a fault is generated
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_100_500.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_L_MAX_ABS_CURRENT
#define MCCONF_L_MAX_ABS_CURRENT 650.0 // The maximum absolute current above which a fault is generated
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_140_300.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_L_MAX_ABS_CURRENT
#define MCCONF_L_MAX_ABS_CURRENT 450.0 // The maximum absolute current above which a fault is generated
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_75_300.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_L_MAX_ABS_CURRENT
#define MCCONF_L_MAX_ABS_CURRENT 420.0 // The maximum absolute current above which a fault is generated
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_Cheap_FOCer_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
#endif

#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 20000.0
#define MCCONF_FOC_F_SW 10000.0
#endif

#ifndef MCCONF_L_CURRENT_MAX
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_Little_FOCer.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 20000.0
#define MCCONF_FOC_F_SW 10000.0
#endif

// Setting limits
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_a200s_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_L_MAX_ABS_CURRENT
#define MCCONF_L_MAX_ABS_CURRENT 180.0 // The maximum absolute current above which a fault is generated
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_a50s.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 35000.0
#define MCCONF_FOC_F_SW 17500.0
#endif
#ifndef MCCONF_L_MAX_ABS_CURRENT
#define MCCONF_L_MAX_ABS_CURRENT 80.0 // The maximum absolute current above which a fault is generated
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_das_mini.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
#define MCCONF_L_MAX_ABS_CURRENT 40.0 // The maximum absolute current above which a fault is generated
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_FOC_SAMPLE_V0_V7
#define MCCONF_FOC_SAMPLE_V0_V7 false // Run control loop in both v0 and v7 (requires phase shunts)
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_das_rs.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
#define MCCONF_FOC_CURRENT_KI 5800.0
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 20000.0
#define MCCONF_FOC_F_SW 10000.0
#endif
#ifndef MCCONF_FOC_MOTOR_L
#define MCCONF_FOC_MOTOR_L 0.0048
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_es19.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_L_MAX_ABS_CURRENT
#define MCCONF_L_MAX_ABS_CURRENT 700.0 // The maximum absolute current above which a fault is generated
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_gesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_L_MAX_ABS_CURRENT
#define MCCONF_L_MAX_ABS_CURRENT 120.0 // The maximum absolute current above which a fault is generated
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_hd60.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif

#ifndef MCCONF_M_DRV8301_OC_MODE
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_hd75.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif

#ifndef APPCONF_SHUTDOWN_MODE
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_raiden7.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
#define MCCONF_L_MAX_VOLTAGE 84.0 // Maximum input voltage
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 20000.0
#define MCCONF_FOC_F_SW 10000.0
#endif
#ifndef MCCONF_FOC_DT_US
#define MCCONF_FOC_DT_US 0.2 // Microseconds for dead time compensation
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_rd2.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
#define MCCONF_FOC_CURRENT_KI 6.0
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_FOC_MOTOR_L
#define MCCONF_FOC_MOTOR_L 6.0e-6
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_uavc_omega.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif

// Setting limits
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_uavc_qcube.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_FOC_SAMPLE_V0_V7
#define MCCONF_FOC_SAMPLE_V0_V7 false // Run control loop in both v0 and v7 (requires phase shunts)
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_ubox_single.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif

#ifndef MCCONF_L_MAX_ABS_CURRENT
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_uxv_sr.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
#define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 30000.0
#define MCCONF_FOC_F_SW 15000.0
#endif
#ifndef MCCONF_FOC_OPENLOOP_RPM
#define MCCONF_FOC_OPENLOOP_RPM 1500.0 // Openloop RPM (sensorless low speed or when finding index pulse)
Expand Down
2 changes: 1 addition & 1 deletion hwconf/hw_warrior6.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
#define MCCONF_FOC_SAMPLE_V0_V7 false // Run control loop in both v0 and v7 (requires phase shunts)
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 20000.0
#define MCCONF_FOC_F_SW 10000.0
#endif
#ifndef MCCONF_L_IN_CURRENT_MAX
#define MCCONF_L_IN_CURRENT_MAX 40.0 // Input current limit in Amperes (Upper)
Expand Down
2 changes: 1 addition & 1 deletion hwconf/luna/mcconf_luna_bbshd_52v.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
#define MCCONF_FOC_CURRENT_KI 32.6

// Switching Frequency
#define MCCONF_FOC_F_SW 50000
#define MCCONF_FOC_F_SW 25000

// Dead Time Compensation
#define MCCONF_FOC_DT_US 0.12
Expand Down
2 changes: 1 addition & 1 deletion mcconf/mcconf_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
#define MCCONF_FOC_CURRENT_KI 50.0
#endif
#ifndef MCCONF_FOC_F_SW
#define MCCONF_FOC_F_SW 25000.0
#define MCCONF_FOC_F_SW 12500.0
#endif
#ifndef MCCONF_FOC_DT_US
#define MCCONF_FOC_DT_US 0.12 // Microseconds for dead time compensation
Expand Down
34 changes: 17 additions & 17 deletions mcpwm_foc.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ static void timer_reinit(int f_sw) {
// Time Base configuration
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_CenterAligned1;
TIM_TimeBaseStructure.TIM_Period = (SYSTEM_CORE_CLOCK / f_sw);
TIM_TimeBaseStructure.TIM_Period = ((SYSTEM_CORE_CLOCK / 2) / f_sw); //Since the counter counts up and down to complete 1 period, divide by 2 is required to get the set frequency.
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;

Expand Down Expand Up @@ -746,7 +746,7 @@ void mcpwm_foc_set_configuration(volatile mc_configuration *configuration) {

// Below we check if anything in the configuration changed that requires stopping the motor.

uint32_t top = SYSTEM_CORE_CLOCK / (int)configuration->foc_f_sw;
uint32_t top = SYSTEM_CORE_CLOCK / (2 * (int)configuration->foc_f_sw);
if (TIM1->ARR != top) {
#ifdef HW_HAS_DUAL_MOTORS
m_motor_1.m_control_mode = CONTROL_MODE_NONE;
Expand Down Expand Up @@ -1125,12 +1125,12 @@ float mcpwm_foc_get_switching_frequency_now(void) {
float mcpwm_foc_get_sampling_frequency_now(void) {
#ifdef HW_HAS_PHASE_SHUNTS
if (motor_now()->m_conf->foc_sample_v0_v7) {
return motor_now()->m_conf->foc_f_sw;
return motor_now()->m_conf->foc_f_sw * 2.0; //Sampling frequency is double when measuring twice per period.
} else {
return motor_now()->m_conf->foc_f_sw / 2.0;
return motor_now()->m_conf->foc_f_sw;
}
#else
return motor_now()->m_conf->foc_f_sw / 2.0;
return motor_now()->m_conf->foc_f_sw;
#endif
}

Expand All @@ -1140,12 +1140,12 @@ float mcpwm_foc_get_sampling_frequency_now(void) {
float mcpwm_foc_get_ts(void) {
#ifdef HW_HAS_PHASE_SHUNTS
if (motor_now()->m_conf->foc_sample_v0_v7) {
return (1.0 / motor_now()->m_conf->foc_f_sw) ;
return (0.5 / motor_now()->m_conf->foc_f_sw ); //Sample time is half when measuring twice per period.
} else {
return (1.0 / (motor_now()->m_conf->foc_f_sw / 2.0));
return (1.0 / motor_now()->m_conf->foc_f_sw);
}
#else
return (1.0 / motor_now()->m_conf->foc_f_sw) ;
return (1.0 / motor_now()->m_conf->foc_f_sw ) ; //Adjusted this to match foc_sample_v0_v7 disabled. Was a bug?
#endif
}

Expand Down Expand Up @@ -1841,8 +1841,8 @@ float mcpwm_foc_measure_inductance(float duty, int samples, float *curr, float *
motor->m_conf->foc_hfi_samples = HFI_SAMPLES_32;
motor->m_conf->foc_sample_high_current = false;

if (motor->m_conf->foc_f_sw > 30.0e3) {
motor->m_conf->foc_f_sw = 30.0e3;
if (motor->m_conf->foc_f_sw > 15.0e3) {
motor->m_conf->foc_f_sw = 15.0e3;
}

mcpwm_foc_set_configuration(motor->m_conf);
Expand Down Expand Up @@ -2609,12 +2609,12 @@ void mcpwm_foc_adc_int_handler(void *p, uint32_t flags) {
#ifdef HW_HAS_PHASE_SHUNTS
float dt;
if (conf_now->foc_sample_v0_v7) {
dt = 1.0 / conf_now->foc_f_sw;
dt = 0.5 / conf_now->foc_f_sw; //Sample time is half when measuring twice per period.
} else {
dt = 1.0 / (conf_now->foc_f_sw / 2.0);
dt = 1.0 / conf_now->foc_f_sw;
}
#else
float dt = 1.0 / (conf_now->foc_f_sw / 2.0);
float dt = 1.0 / conf_now->foc_f_sw;
#endif

// This has to be done for the skip function to have any chance at working with the
Expand Down Expand Up @@ -3488,9 +3488,9 @@ static void hfi_update(volatile motor_all_state_t *motor) {
// we should lag 1/2 HFI buffer behind in phase. Compensate for that here.
float dt_sw;
if (motor->m_conf->foc_sample_v0_v7) {
dt_sw = 1.0 / motor->m_conf->foc_f_sw;
dt_sw = 0.5 / motor->m_conf->foc_f_sw; //Sample time is half when measuring twice per period.
} else {
dt_sw = 1.0 / (motor->m_conf->foc_f_sw / 2.0);
dt_sw = 1.0 / motor->m_conf->foc_f_sw;
}
angle_bin_2 += motor->m_motor_state.speed_rad_s * ((float)motor->m_hfi.samples / 2.0) * dt_sw;

Expand Down Expand Up @@ -3946,7 +3946,7 @@ static void control_current(volatile motor_all_state_t *motor, float dt) {
motor->m_hfi.buffer_current[motor->m_hfi.ind] = di;

if (di > 0.01) {
motor->m_hfi.buffer[motor->m_hfi.ind] = hfi_voltage / (conf_now->foc_f_sw * di);
motor->m_hfi.buffer[motor->m_hfi.ind] = hfi_voltage / (2.0 * conf_now->foc_f_sw * di); //Not understood by me (Elwin), only made consistent with previous code
}

motor->m_hfi.ind++;
Expand Down Expand Up @@ -4075,7 +4075,7 @@ static void update_valpha_vbeta(volatile motor_all_state_t *motor, float mod_alp
const float mod_alpha_filter_sgn = (1.0 / 3.0) * (2.0 * SIGN(ia_filter) - SIGN(ib_filter) - SIGN(ic_filter));
const float mod_beta_filter_sgn = ONE_BY_SQRT3 * (SIGN(ib_filter) - SIGN(ic_filter));

const float mod_comp_fact = conf_now->foc_dt_us * 1e-6 * conf_now->foc_f_sw;
const float mod_comp_fact = conf_now->foc_dt_us * 1e-6 * 2.0 * conf_now->foc_f_sw; //Not understood by me (Elwin), only made consistent with previous code
const float mod_alpha_comp = mod_alpha_filter_sgn * mod_comp_fact;
const float mod_beta_comp = mod_beta_filter_sgn * mod_comp_fact;

Expand Down
Loading