383 lines
6.8 KiB
C
383 lines
6.8 KiB
C
#include "mcu_wrapper_conf.h"
|
|
#include "pwm_sim.h"
|
|
//#include "edrk_main.h"
|
|
//#include "vector.h"
|
|
//#include "vector_control.h"
|
|
//
|
|
//#include "xp_project.h"
|
|
//#include "xp_write_xpwm_time.h"
|
|
//#include "edrk_main.h"
|
|
//#include "vector.h"
|
|
//#include "vector_control.h"
|
|
//#include "v_rotor.h"
|
|
|
|
|
|
|
|
T_project project = {0};
|
|
|
|
|
|
WINDING a;
|
|
EDRK edrk = EDRK_DEFAULT;
|
|
FLAG f = FLAG_DEFAULTS;
|
|
|
|
WRotorValues WRotor = WRotorValues_DEFAULTS;
|
|
WRotorValuesAngle WRotorPBus = WRotorValuesAngle_DEFAULTS;
|
|
|
|
|
|
|
|
|
|
void mcu_simulate_step(void)
|
|
{
|
|
int ff = 0;
|
|
static _iq Uzad1 = 0, Fzad = 0, Uzad2 = 0, Izad_out = 0, Uzad_from_master = 0;
|
|
int pwm_enable_calc_main;
|
|
_iq wd;
|
|
|
|
if (edrk.flag_second_PCH == 0) {
|
|
wd = uf_alg.winding_displacement_bs1;
|
|
}
|
|
else {
|
|
wd = uf_alg.winding_displacement_bs2;
|
|
}
|
|
|
|
detect_level_interrupt();
|
|
if (xpwm_time.where_interrupt == PWM_LOW_LEVEL_INTERRUPT ||
|
|
xpwm_time.one_or_two_interrupts_run == PWM_ONE_INTERRUPT_RUN)
|
|
{
|
|
pwm_enable_calc_main = 1;
|
|
}
|
|
else
|
|
{
|
|
pwm_enable_calc_main = 0;
|
|
}
|
|
|
|
|
|
ramp_all_zadanie(0); // òóò âñå ïî øòàòíîìó
|
|
|
|
calc_norm_ADC(0);
|
|
|
|
|
|
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);
|
|
else
|
|
{
|
|
if (pwm_enable_calc_main)
|
|
write_swgen_pwm_times(PWM_MODE_RELOAD_LEVEL_HIGH);
|
|
else
|
|
write_swgen_pwm_times(PWM_MODE_RELOAD_LEVEL_LOW);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int ReadMemory(unsigned long addr)
|
|
{
|
|
unsigned int returnval = 0;
|
|
if (addr == ADR_SAW_VALUE)
|
|
returnval = t1sim.tcnt;
|
|
//return (*(volatile int *)(addr));
|
|
return returnval;
|
|
}
|
|
|
|
|
|
void WriteMemory(unsigned long addr, unsigned int data)
|
|
{
|
|
//(*(volatile int *)( addr )) = data;
|
|
}
|
|
|
|
|
|
void project_read_all_pbus2()
|
|
{
|
|
|
|
}
|
|
|
|
#pragma DATA_SECTION(break_result_1,".fast_vars");
|
|
_iq break_result_1 = 0;
|
|
|
|
#pragma DATA_SECTION(break_result_2,".fast_vars");
|
|
_iq break_result_2 = 0;
|
|
|
|
#pragma DATA_SECTION(break_result_3,".fast_vars");
|
|
_iq break_result_3 = 0;
|
|
|
|
#pragma DATA_SECTION(break_result_4,".fast_vars");
|
|
_iq break_result_4 = 0;
|
|
|
|
//void read_in_sensor_line1(T_cds_in_rotation_sensor *rs){
|
|
//
|
|
//}
|
|
//
|
|
//void read_in_sensor_line2(T_cds_in_rotation_sensor *rs){
|
|
//
|
|
//}
|
|
//void read_command_reg(T_cds_in_rotation_sensor *rs){
|
|
//
|
|
//}
|
|
//void write_command_reg(T_cds_in_rotation_sensor *rs){
|
|
//
|
|
//}
|
|
//void tune_sampling_time(T_rotation_sensor *rs){
|
|
//
|
|
//}
|
|
//void wait_for_registers_updated(T_cds_in_rotation_sensor *rs){
|
|
//
|
|
//}
|
|
//void read_direction_in_plane(T_cds_in_rotation_sensor *rs){
|
|
//
|
|
//}
|
|
//void sensor_set(T_rotation_sensor *rs)
|
|
//{
|
|
//
|
|
//}
|
|
//void sensor_read(T_rotation_sensor *rs)
|
|
//{
|
|
//
|
|
//}
|
|
//void update_sensors_data(T_rotation_sensor *rs)
|
|
//{
|
|
// // rs->in_plane.write.regs.comand_reg.bit.update_registers = 1;
|
|
// // write_command_reg(&rs->in_plane);
|
|
//// rs->in_plane.write.regs.comand_reg.bit.update_registers = 0;
|
|
//}
|
|
//void angle_sensor_read(T_cds_angle_sensor *as)
|
|
//{}
|
|
//
|
|
//void angle_plane_set(T_cds_angle_sensor *rs)
|
|
//{}
|
|
//void in_plane_set(T_cds_in_rotation_sensor* rs)
|
|
//{}
|
|
//
|
|
//void in_sensor_read1(T_cds_in_rotation_sensor *rs)
|
|
//{}
|
|
//
|
|
//void in_sensor_read2(T_cds_in_rotation_sensor *rs)
|
|
//{}
|
|
|
|
|
|
|
|
|
|
// unsigned int BWC_Started()
|
|
// {
|
|
|
|
// }
|
|
|
|
void update_uom(void)
|
|
{
|
|
|
|
}
|
|
|
|
void inc_RS_timeout_cicle(void)
|
|
{
|
|
|
|
}
|
|
|
|
void inc_CAN_timeout_cicle(void)
|
|
{
|
|
|
|
}
|
|
|
|
void pause_1000(void)
|
|
{
|
|
|
|
}
|
|
|
|
int xerror(unsigned int er_ID, void* CallBackRef)
|
|
{
|
|
};
|
|
|
|
void func_unpack_answer_from_Ingeteam(unsigned int a) {}
|
|
void unpack_answer_from_MPU_SVU_CAN(unsigned int a) {}
|
|
int get_real_in_mbox(int a, int b) {}
|
|
|
|
void start_pwm(void)
|
|
{
|
|
// mPWM_a = 1;
|
|
// mPWM_b = 1;
|
|
}
|
|
|
|
void stop_pwm(void)
|
|
{
|
|
// mPWM_a = 0;
|
|
// mPWM_b = 0;
|
|
|
|
// svgen_set_time_keys_closed(&svgen_pwm24_1);
|
|
// svgen_set_time_keys_closed(&svgen_pwm24_2);
|
|
// WriteMemory(ADR_TK_MASK_0, 0xFFFF);
|
|
// WriteMemory(ADR_PWM_START_STOP, 0x8000);
|
|
}
|
|
void start_break_pwm() {
|
|
|
|
}
|
|
|
|
|
|
void stop_break_pwm() {
|
|
|
|
}
|
|
|
|
void stop_wdog() {
|
|
|
|
}
|
|
|
|
void start_pwm_b() {
|
|
|
|
}
|
|
void start_pwm_a() {
|
|
|
|
}
|
|
void stop_pwm_b() {
|
|
|
|
}
|
|
void stop_pwm_a() {
|
|
|
|
}
|
|
|
|
void fillADClogs() {
|
|
|
|
}
|
|
void break_resistor_managment_calc(){
|
|
|
|
}
|
|
|
|
|
|
void break_resistor_managment_init(){
|
|
|
|
}
|
|
|
|
|
|
void break_resistor_managment_update(){
|
|
|
|
}
|
|
|
|
|
|
void break_resistor_recup_calc(){
|
|
|
|
}
|
|
|
|
|
|
void break_resistor_set_closed(){
|
|
|
|
}
|
|
|
|
|
|
void DetectI_Out_BreakFase(){
|
|
|
|
}
|
|
|
|
|
|
void test_mem_limit(){
|
|
|
|
}
|
|
|
|
|
|
void set_start_mem(){
|
|
|
|
}
|
|
|
|
|
|
void getFastLogs(){
|
|
|
|
}
|
|
|
|
|
|
//void detect_I_M_overload{
|
|
//
|
|
// }
|
|
|
|
|
|
void sync_inc_error(){
|
|
|
|
}
|
|
|
|
|
|
void optical_bus_read(){
|
|
|
|
}
|
|
|
|
|
|
void optical_bus_write(void){
|
|
|
|
}
|
|
void i_led1_on_off(int i) {}
|
|
void modbus_table_can_in(void) {}
|
|
|
|
void init_flag_a(void)
|
|
{
|
|
|
|
unsigned int i = 0;
|
|
int *pStr = (int*)&f;
|
|
for (i = 0; i < sizeof(f) / sizeof(int); i++) {
|
|
*(pStr + i) = 0;
|
|
}
|
|
|
|
*pStr = (int*)&a;
|
|
for (i = 0; i < sizeof(a) / sizeof(int); i++) {
|
|
*(pStr + i) = 0;
|
|
}
|
|
|
|
|
|
}
|