diff --git a/Inu/Src/main/alg_simple_scalar.c b/Inu/Src/main/alg_simple_scalar.c index 5d9a76f..a678a5d 100644 --- a/Inu/Src/main/alg_simple_scalar.c +++ b/Inu/Src/main/alg_simple_scalar.c @@ -292,11 +292,11 @@ void simple_scalar(int n_alg, int n_wind_pump, if (n_alg==2) mzz_zad_int = zad_intensiv_q(simple_scalar1.mzz_add_2, simple_scalar1.mzz_add_2, mzz_zad_int, mzz_zad); -// myq_temp = _IQdiv(mzz_zad, simple_scalar1.iq_mzz_max_for_fzad); + myq_temp = _IQdiv(mzz_zad, simple_scalar1.iq_mzz_max_for_fzad); -// myq_temp = _IQmpy( myq_temp, fzad_add_max); + myq_temp = _IQsat( myq_temp, simple_scalar1.fzad_add_max, 0); - // fzad_add = myq_temp; + fzad_add = myq_temp; fzad_int = zad_intensiv_q(fzad_add, fzad_add, fzad_int, fzad); diff --git a/Inu/Src/main/params_pwm24.h b/Inu/Src/main/params_pwm24.h index 28319cf..9774dbe 100644 --- a/Inu/Src/main/params_pwm24.h +++ b/Inu/Src/main/params_pwm24.h @@ -12,7 +12,7 @@ #define FREQ_PWM 450 //800 /* частота ШИМа */ //3138 // 2360//2477 // -#define DEF_PERIOD_MIN_MKS 80 //60 // берем минимальное время работы ключа = 2*TK_MIN_TIME_MKS = 30 с запасом +#define DEF_PERIOD_MIN_MKS 0 //60 // берем минимальное время работы ключа = 2*TK_MIN_TIME_MKS = 30 с запасом // + TK_DEAD_TIME_MKS + 5mks запас = 60 #define DEF_PERIOD_MIN_BR_XTICS 165 diff --git a/Inu/def.h b/Inu/def.h index 12cca02..4cc3abc 100644 --- a/Inu/def.h +++ b/Inu/def.h @@ -11,7 +11,7 @@ // раскомментировать, если есть сдвиг между обмотками ГЭД (30 град.) #define SHIFT -#define SIMULINK_SEQUENCE V_PWM24_PHASE_SEQ_REVERS_BAC +#define SIMULINK_SEQUENCE V_PWM24_PHASE_SEQ_NORMAL_ABC /* V_PWM24_PHASE_SEQ_NORMAL_ABC, - не то V_PWM24_PHASE_SEQ_NORMAL_BCA, - похоже на правду V_PWM24_PHASE_SEQ_NORMAL_CAB, - жопа diff --git a/Inu/main_matlab/init28335.c b/Inu/main_matlab/init28335.c index 7a096e1..e7ba375 100644 --- a/Inu/main_matlab/init28335.c +++ b/Inu/main_matlab/init28335.c @@ -31,8 +31,9 @@ void init28335(void) { //svgen_pwm24_1.phase_sequence = SIMULINK_SEQUENCE; //svgen_pwm24_2.phase_sequence = SIMULINK_SEQUENCE; - edrk.zadanie.iq_Izad = _IQ(0.5); - edrk.disable_alg_u_disbalance = 1; + edrk.zadanie.iq_Izad = _IQ(1); + edrk.disable_alg_u_disbalance = 0; + edrk.zadanie.iq_limit_power_zad = _IQ(1); //analog_zero.iqU_1 = 2048; //analog_zero.iqU_2 = 2048; } //void init28335(void) @@ -79,17 +80,54 @@ void edrk_init_matlab(void) edrk.iq_bpsi_normal = _IQ(BPSI_NORMAL / NORMA_FROTOR); // edrk.iq_f_provorot = _IQ(F_PROVOROT/NORMA_FROTOR); + //init_simple_scalar(); + + //edrk.flag_enable_update_hmi = 1; + + + + edrk.Uzad_max = _IQ(K_STATOR_MAX); // макс амплитуда в Км для минимального импульса = DEF_PERIOD_MIN_MKS + edrk.iq_bpsi_normal = _IQ(BPSI_NORMAL / NORMA_FROTOR); + // edrk.iq_bpsi_max = _IQ(BPSI_MAXIMAL/NORMA_FROTOR); + // edrk.iq_f_provorot = _IQ(F_PROVOROT/NORMA_FROTOR); + init_simple_scalar(); edrk.flag_enable_update_hmi = 1; + + + edrk.zadanie.ZadanieU_Charge = 2500; + edrk.zadanie.iq_ZadanieU_Charge = _IQ(2500 / NORMA_ACP); + edrk.temper_limit_koeffs.sum_limit = _IQ(1); + simple_scalar1.fzad_add_max = _IQ(FZAD_ADD_MAX); + edrk.Mode_ScalarVectorUFConst = ALG_MODE_SCALAR_OBOROTS; + + edrk.zadanie.iq_power_zad = _IQ(1); + edrk.zadanie.iq_oborots_zad_hz = _IQ(1); + + edrk.MasterSlave = MODE_MASTER; + edrk.master_theta; + edrk.master_Iq; + edrk.iq_power_kw_another_bs = edrk.P_to_master; + edrk.tetta_to_slave; + edrk.Iq_to_slave; + edrk.P_to_master; + + uf_alg.winding_displacement_bs1; + + //edrk.zadanie.iq_set_break_level = _IQ(2500 / NORMA_ACP); + + control_station.setup_time_detect_active[CONTROL_STATION_TERMINAL_RS232] = 50; + + } void set_zadanie_u_charge_matlab(void) { -// edrk.ZadanieU_Charge = edrk.ZadanieU_Charge_RS; + //edrk.ZadanieU_Charge = edrk.ZadanieU_Charge_RS; -// edrk.iq_ZadanieU_Charge = _IQ(edrk.ZadanieU_Charge/NORMA_ACP); + //edrk.iq_ZadanieU_Charge = _IQ(edrk.ZadanieU_Charge/NORMA_ACP); if (edrk.zadanie.ZadanieU_Charge<=100) { diff --git a/Inu/main_matlab/main_matlab.c b/Inu/main_matlab/main_matlab.c index aeb75c3..dacf093 100644 --- a/Inu/main_matlab/main_matlab.c +++ b/Inu/main_matlab/main_matlab.c @@ -56,26 +56,67 @@ void mcu_simulate_step(void) calc_norm_ADC(0); - vectorControlConstId(edrk.zadanie.iq_power_zad_rmp, edrk.zadanie.iq_oborots_zad_hz_rmp, - WRotorPBus.RotorDirection1, WRotor.iqWRotorCalcBeforeRegul1, - edrk.Mode_ScalarVectorUFConst, - edrk.MasterSlave, edrk.zadanie.iq_Izad, wd, - edrk.master_theta, edrk.master_Iq, edrk.iq_power_kw_another_bs, - &edrk.tetta_to_slave, &edrk.Iq_to_slave, &edrk.P_to_master, - 0, 0); - test_calc_vect_dq_pwm24_Ing(vect_control.iqTheta, vect_control.iqUdKm, vect_control.iqUqKm, - edrk.disable_alg_u_disbalance, - edrk.zadanie.iq_kplus_u_disbalance_rmp, edrk.zadanie.iq_k_u_disbalance_rmp, - filter.iqU_1_fast, filter.iqU_2_fast, - 0, - edrk.Uzad_max, - edrk.MasterSlave, - edrk.flag_second_PCH, - &edrk.Kplus, &edrk.Uzad_to_slave); - analog.PowerFOC = edrk.P_to_master; - Fzad = vect_control.iqFstator; - Izad_out = edrk.Iq_to_slave; + if (edrk.Mode_ScalarVectorUFConst == ALG_MODE_SCALAR_OBOROTS || edrk.Mode_ScalarVectorUFConst == ALG_MODE_SCALAR_POWER) + { +#if(_ENABLE_PWM_LINES_FOR_TESTS_PWM) + PWM_LINES_TK_20_ON; +#endif + simple_scalar(1, 0, + WRotor.iqWRotorCalcBeforeRegul1, WRotor.iqWRotorCalcBeforeRegul1, edrk.zadanie.iq_oborots_zad_hz_rmp, + edrk.temper_limit_koeffs.sum_limit, + edrk.zadanie.iq_Izad_rmp, edrk.iq_bpsi_normal, + analog.iqIm, + // analog.iqU_1_long+analog.iqU_2_long, + edrk.zadanie.iq_ZadanieU_Charge_rmp + edrk.zadanie.iq_ZadanieU_Charge_rmp, + analog.iqIin_sum, + edrk.zadanie.iq_power_zad_rmp, (filter.PowerScalar + edrk.iq_power_kw_another_bs), + edrk.master_Izad, edrk.MasterSlave, + &Fzad, &Uzad1, &Uzad2, &Izad_out); + + test_calc_simple_dq_pwm24_Ing(Fzad, Uzad1, edrk.disable_alg_u_disbalance, + edrk.zadanie.iq_kplus_u_disbalance, edrk.zadanie.iq_k_u_disbalance, filter.iqU_1_fast, filter.iqU_2_fast, + 0, + edrk.Uzad_max, + edrk.master_theta, + Uzad1, //edrk.master_Uzad, + edrk.MasterSlave, + edrk.flag_second_PCH, + &edrk.Kplus, &edrk.tetta_to_slave, &edrk.Uzad_to_slave); + + } // end ALG_MODE_SCALAR + else + { + if (edrk.flag_second_PCH == 0) { + wd = uf_alg.winding_displacement_bs1; + } + else { + wd = uf_alg.winding_displacement_bs2; + } + + analog_dq_calc_external(wd, uf_alg.tetta); + + vectorControlConstId(edrk.zadanie.iq_power_zad_rmp, edrk.zadanie.iq_oborots_zad_hz_rmp, + WRotorPBus.RotorDirection1, WRotor.iqWRotorCalcBeforeRegul1, + edrk.Mode_ScalarVectorUFConst, + edrk.MasterSlave, edrk.zadanie.iq_Izad, wd, + edrk.master_theta, edrk.master_Iq, edrk.iq_power_kw_another_bs, + &edrk.tetta_to_slave, &edrk.Iq_to_slave, &edrk.P_to_master, + 0, 0); + + test_calc_vect_dq_pwm24_Ing(vect_control.iqTheta, vect_control.iqUdKm, vect_control.iqUqKm, + edrk.disable_alg_u_disbalance, + edrk.zadanie.iq_kplus_u_disbalance_rmp, edrk.zadanie.iq_k_u_disbalance_rmp, + filter.iqU_1_fast, filter.iqU_2_fast, + 0, + edrk.Uzad_max, + edrk.MasterSlave, + edrk.flag_second_PCH, + &edrk.Kplus, &edrk.Uzad_to_slave); + analog.PowerFOC = edrk.P_to_master; + Fzad = vect_control.iqFstator; + Izad_out = edrk.Iq_to_slave; + }// end ALG_MODE_FOC if (xpwm_time.one_or_two_interrupts_run == PWM_ONE_INTERRUPT_RUN) write_swgen_pwm_times(PWM_MODE_RELOAD_FORCE); diff --git a/Inu/main_matlab/param.c b/Inu/main_matlab/param.c index 1294f49..19844ad 100644 --- a/Inu/main_matlab/param.c +++ b/Inu/main_matlab/param.c @@ -32,36 +32,52 @@ void readInputParameters(const real_T *u) { edrk.Go = u[nn++]; u[nn++]; - edrk.Mode_ScalarVectorUFConst = ALG_MODE_FOC_POWER; - - edrk.zadanie.iq_power_zad = _IQ(0.5); - edrk.zadanie.iq_oborots_zad_hz = _IQ(0.5); - - edrk.MasterSlave = MODE_MASTER; - edrk.master_theta; - edrk.master_Iq; - edrk.iq_power_kw_another_bs; - edrk.tetta_to_slave; - edrk.Iq_to_slave; - edrk.P_to_master; - - uf_alg.winding_displacement_bs1; } //void input_param(unsigned short num, unsigned short val) void writeOutputParameters(real_T* xD) { int nn = 0; + //xD[nn++] = t2sim.ciA; + //xD[nn++] = t1sim.ciA; + //xD[nn++] = t2sim.ciB; + //xD[nn++] = t1sim.ciB; + // + //xD[nn++] = t4sim.ciA; + //xD[nn++] = t3sim.ciA; + //xD[nn++] = t4sim.ciB; + //xD[nn++] = t3sim.ciB; + // + //xD[nn++] = t6sim.ciA; + //xD[nn++] = t5sim.ciA; + //xD[nn++] = t6sim.ciB; + //xD[nn++] = t5sim.ciB; + + //xD[nn++] = t1sim.ciB; + //xD[nn++] = t2sim.ciB; + //xD[nn++] = t1sim.ciA; + //xD[nn++] = t2sim.ciA; + + //xD[nn++] = t3sim.ciB; + //xD[nn++] = t4sim.ciB; + //xD[nn++] = t3sim.ciA; + //xD[nn++] = t4sim.ciA; + // + //xD[nn++] = t5sim.ciB; + //xD[nn++] = t6sim.ciB; + //xD[nn++] = t5sim.ciA; + //xD[nn++] = t6sim.ciA; + xD[nn++] = t1sim.ciA; xD[nn++] = t2sim.ciA; xD[nn++] = t1sim.ciB; xD[nn++] = t2sim.ciB; - + xD[nn++] = t3sim.ciA; xD[nn++] = t4sim.ciA; xD[nn++] = t3sim.ciB; xD[nn++] = t4sim.ciB; - + xD[nn++] = t5sim.ciA; xD[nn++] = t6sim.ciA; xD[nn++] = t5sim.ciB; diff --git a/Inu/main_matlab/pwm_sim.c b/Inu/main_matlab/pwm_sim.c index 395fa9a..c3ac5f7 100644 --- a/Inu/main_matlab/pwm_sim.c +++ b/Inu/main_matlab/pwm_sim.c @@ -15,18 +15,18 @@ TimerSimHandle t12sim; void Simulate_Timers(void) { - SimulateMainPWM(&t1sim, xpwm_time.Ta0_0); - SimulatePWM(&t2sim, xpwm_time.Ta0_1); - SimulatePWM(&t3sim, xpwm_time.Tb0_0); - SimulatePWM(&t4sim, xpwm_time.Tb0_1); - SimulatePWM(&t5sim, xpwm_time.Tc0_0); - SimulatePWM(&t6sim, xpwm_time.Tc0_1); - SimulatePWM(&t7sim, xpwm_time.Ta1_0); - SimulatePWM(&t8sim, xpwm_time.Ta1_1); - SimulatePWM(&t9sim, xpwm_time.Tb1_0); - SimulatePWM(&t10sim, xpwm_time.Tb1_1); - SimulatePWM(&t11sim, xpwm_time.Tc1_0); - SimulatePWM(&t12sim, xpwm_time.Tc1_1); + SimulateMainPWM(&t1sim, xpwm_time.Ta0_1); + SimulateSimplePWM(&t2sim, xpwm_time.Ta0_0); + SimulateSimplePWM(&t3sim, xpwm_time.Tb0_1); + SimulateSimplePWM(&t4sim, xpwm_time.Tb0_0); + SimulateSimplePWM(&t5sim, xpwm_time.Tc0_1); + SimulateSimplePWM(&t6sim, xpwm_time.Tc0_0); + SimulateSimplePWM(&t7sim, xpwm_time.Ta1_1); + SimulateSimplePWM(&t8sim, xpwm_time.Ta1_0); + SimulateSimplePWM(&t9sim, xpwm_time.Tb1_1); + SimulateSimplePWM(&t10sim, xpwm_time.Tb1_0); + SimulateSimplePWM(&t11sim, xpwm_time.Tc1_1); + SimulateSimplePWM(&t12sim, xpwm_time.Tc1_0); } void Init_Timers(void) @@ -52,12 +52,16 @@ void initSimulateTim(TimerSimHandle* tsim, int period, double step) { tsim->dtsim.stateDt = 1; tsim->TPr = period; - tsim->TxCntPlus = step; + tsim->TxCntPlus = step*2; tsim->dtsim.DtCntPeriod = (int)(DT / hmcu.SimSampleTime); } void SimulateMainPWM(TimerSimHandle* tsim, int compare) { +#ifdef UNITED_COUNTER + tsim->tcntAuxPrev = tsim->tcntAux; + tsim->tcntAux += tsim->TxCntPlus; +#endif if (simulateTimAndGetCompare(tsim, compare)) mcu_simulate_step(); simulateActionActionQualifierSubmodule(tsim); @@ -65,9 +69,9 @@ void SimulateMainPWM(TimerSimHandle* tsim, int compare) simulateTripZoneSubmodule(tsim); } -void SimulatePWM(TimerSimHandle* tsim, int compare) +void SimulateSimplePWM(TimerSimHandle* tsim, int compare) { - simulateTimAndGetCompare(tsim, compare); + simulateTimAndGetCompare(tsim, compare, 0); simulateActionActionQualifierSubmodule(tsim); //tsim->ciA = tsim->dtsim.ciA_DT; //tsim->ciB = tsim->dtsim.ciB_DT; @@ -76,11 +80,17 @@ void SimulatePWM(TimerSimHandle* tsim, int compare) } -int simulateTimAndGetCompare(TimerSimHandle *tsim, int compare) +int simulateTimAndGetCompare(TimerSimHandle* tsim, int compare) { int interruptflag = 0; + +#ifdef UNITED_COUNTER + tsim->tcntAuxPrev = t1sim.tcntAuxPrev; + tsim->tcntAux = t1sim.tcntAux; +#else tsim->tcntAuxPrev = tsim->tcntAux; tsim->tcntAux += tsim->TxCntPlus; +#endif if (tsim->tcntAux > tsim->TPr) { tsim->tcntAux -= tsim->TPr * 2.; diff --git a/Inu/main_matlab/pwm_sim.h b/Inu/main_matlab/pwm_sim.h index 7a611b1..dfff77d 100644 --- a/Inu/main_matlab/pwm_sim.h +++ b/Inu/main_matlab/pwm_sim.h @@ -4,6 +4,8 @@ #define PWM_SIM +#define UNITED_COUNTER + // Для моделирования Event Manager // ... Dead-Band Submodule typedef struct @@ -44,14 +46,13 @@ extern TimerSimHandle t11sim; extern TimerSimHandle t12sim; - void Simulate_Timers(void); void Init_Timers(void); void initSimulateTim(TimerSimHandle* tsim, int period, double step); void SimulateMainPWM(TimerSimHandle* tsim, int compare); -void SimulatePWM(TimerSimHandle* tsim, int compare); +void SimulateSimplePWM(TimerSimHandle* tsim, int compare); int simulateTimAndGetCompare(TimerSimHandle* tsim, int compare); void simulateActionActionQualifierSubmodule(TimerSimHandle* tsim); void simulateDeadBendSubmodule(TimerSimHandle* tsim); diff --git a/Inu/mcu_app_includes.h b/Inu/mcu_app_includes.h index cfd1782..edad913 100644 --- a/Inu/mcu_app_includes.h +++ b/Inu/mcu_app_includes.h @@ -33,6 +33,7 @@ #include "xp_write_xpwm_time.h" #include "global_time.h" #include "PWMTools.h" +#include "alg_simple_scalar.h" #include #include diff --git a/init.m b/init.m index a686576..15e83d0 100644 --- a/init.m +++ b/init.m @@ -27,17 +27,17 @@ NP = 0.08; % номинальные величины ГЭД % ... мощность на валу, Вт -Pnom = 6300e3; +Pnom = 5000e3*2; % ... линейное напряжение, В (rms) -Unom = 3300; +Unom = 3000; % ... механическая скорость, об/мин -NmNom = 180; +NmNom = 165; % ... число пар полюсов Pp = 6; % ... коэффициент мощности CosFi = 0.87; % ... КПД -Eff = 0.968; +Eff = 0.962; % ... приведенный к валу момент инерции, кг*м^2 J = 87e3*0.5; % ... полная мощность, ВА @@ -62,8 +62,8 @@ Rs = 11.8e-3;% Xls = 72.7e-3;%72.7e-3;%Ом Rr = 11.1e-3*2.0;%*0.8;%Ом Xlr = 85.5e-3;%Ом -Xm = 2.9322;%2.87;%Ом -Fe = 18;%Гц +Xm = 2.87 * 1.5;%2.87;%Ом +Fe = 12;%Гц Lls = Xls/(Fe*PI2);%Гн Llr = Xlr/(Fe*PI2);%Гн Lm = Xm/(Fe*PI2);%Гн @@ -71,7 +71,7 @@ Lm = Xm/(Fe*PI2);% % ёмкость на входе INU, Ф Cdc = 50e-3; % снаберы в INU -Csn = Pnom/(1000*WeNom*Unom^2)/10;%Ф (0.5 - т.к. преобразователей два) +Csn = Pnom/(1000*WeNom*Unom^2)/10*0.5;%Ф (0.5 - т.к. преобразователей два) Rsn = 2*Ts/Csn*10;%Ом % постоянная времени фильтра для тока ГЭД, c diff --git a/inu_23550.slx b/inu_23550.slx new file mode 100644 index 0000000..c84b071 Binary files /dev/null and b/inu_23550.slx differ diff --git a/inu_im_2wnd_3lvl.slx b/inu_im_2wnd_3lvl.slx deleted file mode 100644 index 03186e6..0000000 Binary files a/inu_im_2wnd_3lvl.slx and /dev/null differ