2025-01-13 13:05:34 +03:00
|
|
|
|
/**************************************************************************
|
|
|
|
|
Description: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
TMS320F28335/TMS320F28379D.
|
|
|
|
|
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>.<EFBFBD>.
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 2021.10.04
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
2025-01-18 20:07:11 +03:00
|
|
|
|
#include "app_init.h"
|
2025-01-13 13:05:34 +03:00
|
|
|
|
|
|
|
|
|
#define FREQ_TIMER_3 (FREQ_PWM*2)
|
2025-01-15 13:39:33 +03:00
|
|
|
|
#define MAX_U_PROC_SMALL 2.5 //1.4
|
|
|
|
|
#define MAX_U_PROC 1.3 //1.11 //1.4
|
|
|
|
|
#define MIN_U_PROC 0.8 //0.7
|
|
|
|
|
|
|
|
|
|
#define ADD_U_MAX_GLOBAL 200.0 //V <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GLOBAL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZadanieU_Charge
|
|
|
|
|
#define ADD_U_MAX_GLOBAL_SMALL 500.0 //V <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GLOBAL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZadanieU_Charge
|
|
|
|
|
#define LEVEL_DETECT_U_SMALL 1000.0 //V <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GLOBAL <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ZadanieU_Charge
|
2025-01-13 13:05:34 +03:00
|
|
|
|
|
2025-01-18 20:07:11 +03:00
|
|
|
|
void app_init(void) {
|
2025-01-13 13:05:34 +03:00
|
|
|
|
|
|
|
|
|
edrk.flag_second_PCH = 0;
|
|
|
|
|
|
|
|
|
|
edrk_init_variables_matlab();
|
2025-01-15 13:39:33 +03:00
|
|
|
|
init_global_time_struct(FREQ_TIMER_3);
|
2025-01-13 13:05:34 +03:00
|
|
|
|
|
2025-01-13 16:58:59 +03:00
|
|
|
|
Init_Adc_Variables();
|
2025-01-14 13:26:48 +03:00
|
|
|
|
|
2025-01-15 13:39:33 +03:00
|
|
|
|
//svgen_pwm24_1.phase_sequence = SIMULINK_SEQUENCE;
|
|
|
|
|
//svgen_pwm24_2.phase_sequence = SIMULINK_SEQUENCE;
|
2025-01-13 13:05:34 +03:00
|
|
|
|
|
2025-01-16 13:10:11 +03:00
|
|
|
|
edrk.zadanie.iq_Izad = _IQ(1);
|
|
|
|
|
edrk.disable_alg_u_disbalance = 0;
|
|
|
|
|
edrk.zadanie.iq_limit_power_zad = _IQ(1);
|
2025-01-18 20:07:11 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
2025-01-20 11:41:55 +03:00
|
|
|
|
edrk.Mode_ScalarVectorUFConst = ALG_MODE_SIMULINK;
|
2025-01-20 10:45:47 +03:00
|
|
|
|
//edrk.Mode_ScalarVectorUFConst = ALG_MODE_FOC_OBOROTS;
|
2025-01-18 20:07:11 +03:00
|
|
|
|
|
|
|
|
|
edrk.zadanie.iq_power_zad = _IQ(1);
|
2025-01-20 10:45:47 +03:00
|
|
|
|
edrk.zadanie.iq_oborots_zad_hz = _IQ(1);
|
2025-01-18 20:07:11 +03:00
|
|
|
|
|
|
|
|
|
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;
|
2025-01-14 16:36:57 +03:00
|
|
|
|
//analog_zero.iqU_1 = 2048;
|
|
|
|
|
//analog_zero.iqU_2 = 2048;
|
2025-01-13 13:05:34 +03:00
|
|
|
|
} //void init28335(void)
|
|
|
|
|
|
|
|
|
|
void edrk_init_variables_matlab(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
initVectorControl();
|
|
|
|
|
InitXPWM(FREQ_PWM);
|
2025-01-15 13:39:33 +03:00
|
|
|
|
InitPWM_Variables();
|
2025-01-13 13:05:34 +03:00
|
|
|
|
|
|
|
|
|
//#if(SENSOR_ALG==SENSOR_ALG_23550)
|
|
|
|
|
// rotorInit();
|
|
|
|
|
//#endif
|
|
|
|
|
//#if(SENSOR_ALG==SENSOR_ALG_22220)
|
|
|
|
|
// // 22220
|
|
|
|
|
// rotorInit_22220();
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
control_station.clear(&control_station);
|
|
|
|
|
|
|
|
|
|
edrk_init_matlab();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init_ramp_all_zadanie();
|
2025-01-15 13:39:33 +03:00
|
|
|
|
//init_all_limit_koeffs();
|
2025-01-13 16:58:59 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < CONTROL_STATION_CMD_LAST; i++)
|
|
|
|
|
control_station.array_cmd[CONTROL_STATION_TERMINAL_CAN][i] = control_station.array_cmd[CONTROL_STATION_TERMINAL_RS232][i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ramp_all_zadanie(2);
|
|
|
|
|
|
|
|
|
|
set_zadanie_u_charge_matlab();
|
|
|
|
|
init_Uin_rms();
|
2025-01-13 13:05:34 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void edrk_init_matlab(void)
|
|
|
|
|
{
|
|
|
|
|
|
2025-01-15 13:39:33 +03:00
|
|
|
|
edrk.Uzad_max = _IQ(K_STATOR_MAX); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = DEF_PERIOD_MIN_MKS
|
|
|
|
|
edrk.iq_bpsi_normal = _IQ(BPSI_NORMAL / NORMA_FROTOR);
|
|
|
|
|
// edrk.iq_f_provorot = _IQ(F_PROVOROT/NORMA_FROTOR);
|
2025-01-13 13:05:34 +03:00
|
|
|
|
|
2025-01-16 13:10:11 +03:00
|
|
|
|
//init_simple_scalar();
|
|
|
|
|
|
|
|
|
|
//edrk.flag_enable_update_hmi = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
edrk.Uzad_max = _IQ(K_STATOR_MAX); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = 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);
|
|
|
|
|
|
2025-01-15 13:39:33 +03:00
|
|
|
|
init_simple_scalar();
|
2025-01-13 13:05:34 +03:00
|
|
|
|
|
2025-01-15 13:39:33 +03:00
|
|
|
|
edrk.flag_enable_update_hmi = 1;
|
2025-01-16 13:10:11 +03:00
|
|
|
|
|
|
|
|
|
//edrk.zadanie.iq_set_break_level = _IQ(2500 / NORMA_ACP);
|
|
|
|
|
|
|
|
|
|
control_station.setup_time_detect_active[CONTROL_STATION_TERMINAL_RS232] = 50;
|
|
|
|
|
|
|
|
|
|
|
2025-01-13 16:58:59 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_zadanie_u_charge_matlab(void)
|
|
|
|
|
{
|
|
|
|
|
|
2025-01-16 13:10:11 +03:00
|
|
|
|
//edrk.ZadanieU_Charge = edrk.ZadanieU_Charge_RS;
|
2025-01-13 16:58:59 +03:00
|
|
|
|
|
2025-01-16 13:10:11 +03:00
|
|
|
|
//edrk.iq_ZadanieU_Charge = _IQ(edrk.ZadanieU_Charge/NORMA_ACP);
|
2025-01-13 16:58:59 +03:00
|
|
|
|
|
2025-01-15 13:39:33 +03:00
|
|
|
|
if (edrk.zadanie.ZadanieU_Charge<=100)
|
2025-01-13 16:58:59 +03:00
|
|
|
|
{
|
2025-01-15 13:39:33 +03:00
|
|
|
|
edrk.iqMIN_U_ZPT = _IQ(-50.0/NORMA_ACP);
|
|
|
|
|
edrk.iqMIN_U_IN = _IQ(-50.0/NORMA_ACP);
|
2025-01-13 16:58:59 +03:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
2025-01-15 13:39:33 +03:00
|
|
|
|
edrk.iqMIN_U_ZPT = _IQ(edrk.zadanie.ZadanieU_Charge*MIN_U_PROC/NORMA_ACP);
|
|
|
|
|
edrk.iqMIN_U_IN = _IQ(edrk.zadanie.ZadanieU_Charge*MIN_U_PROC/NORMA_ACP);
|
2025-01-13 16:58:59 +03:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-15 13:39:33 +03:00
|
|
|
|
if (edrk.zadanie.ZadanieU_Charge<LEVEL_DETECT_U_SMALL)
|
2025-01-13 16:58:59 +03:00
|
|
|
|
{
|
2025-01-15 13:39:33 +03:00
|
|
|
|
edrk.iqMAX_U_ZPT_Predzaryad = _IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC_SMALL/NORMA_ACP);
|
|
|
|
|
edrk.iqMAX_U_ZPT_Global = edrk.iqMAX_U_ZPT_Predzaryad + _IQ(ADD_U_MAX_GLOBAL_SMALL/NORMA_ACP); // +500V
|
2025-01-13 16:58:59 +03:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-01-15 13:39:33 +03:00
|
|
|
|
edrk.iqMAX_U_ZPT_Predzaryad = _IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC/NORMA_ACP);
|
|
|
|
|
edrk.iqMAX_U_ZPT_Global = edrk.iqMAX_U_ZPT_Predzaryad + _IQ(ADD_U_MAX_GLOBAL/NORMA_ACP); // +200V
|
|
|
|
|
|
|
|
|
|
if (edrk.iqMAX_U_ZPT_Global>U_D_MAX_ERROR_GLOBAL_2800)
|
|
|
|
|
edrk.iqMAX_U_ZPT_Global = U_D_MAX_ERROR_GLOBAL_2800;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
edrk.iqMAX_U_ZPT = _IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC/NORMA_ACP);
|
|
|
|
|
edrk.iqMAX_U_IN = _IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC/NORMA_ACP);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|