/* * pwm_logs.c * * Created on: 19 авг. 2024 г. * Author: user */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "global_time.h" #include "IQmathLib.h" #include "oscil_can.h" #include "uf_alg_ing.h" #include "MemoryFunctions.h" #include "RS_Functions.h" #include "v_rotor_22220.h" #include "log_to_memory.h" #include "log_params.h" #include "logs_hmi.h" #include "vector_control.h" ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// #pragma CODE_SECTION(prepare_data_to_logs,".fast_run"); unsigned int prepare_data_to_logs(void) { logsdata.logs[0] = (int16) global_time.total_seconds10full;// = 0;//(int16)(_IQtoIQ15(Izad)); logsdata.logs[1] = (int16) _IQtoIQ15(analog.iqIu_1); logsdata.logs[2] = (int16) _IQtoIQ15(analog.iqIv_1); logsdata.logs[3] = (int16) _IQtoIQ15(analog.iqIw_1); logsdata.logs[4] = (int16) _IQtoIQ15(analog.iqIu_2); logsdata.logs[5] = (int16) _IQtoIQ15(analog.iqIv_2); logsdata.logs[6] = (int16) _IQtoIQ15(analog.iqIw_2); logsdata.logs[7] = (int16) _IQtoIQ15(analog.iqUin_A1B1);// (int16) _IQtoIQ15(analog.iqUin_m1); logsdata.logs[8] = (int16) _IQtoIQ15(analog.iqUin_A2B2);// (int16) _IQtoIQ15(analog.iqUin_m2); logsdata.logs[9] = (int16) _IQtoIQ15(analog.iqU_1); logsdata.logs[10] = (int16) _IQtoIQ15(analog.iqU_2);//11 logsdata.logs[11] = (int16) _IQtoIQ15(analog.iqIin_1); logsdata.logs[12] = (int16) _IQtoIQ15(analog.iqIin_2); logsdata.logs[13] = (int16) _IQtoIQ15(analog.iqIm_1); logsdata.logs[14] = (int16) _IQtoIQ15(analog.iqIm_2); logsdata.logs[15] = (int16) _IQtoIQ15(analog.iqIbreak_1);//(int16) _IQtoIQ15(filter.iqU_1_long); logsdata.logs[16] = (int16) _IQtoIQ15(analog.iqIbreak_2);//(int16) _IQtoIQ15(filter.iqU_2_long); logsdata.logs[17] = (int16)svgen_pwm24_1.Ta_0; logsdata.logs[18] = (int16)svgen_pwm24_1.Ta_1; logsdata.logs[19] = (int16)break_result_1; logsdata.logs[20] = (int16)break_result_2; // logpar.log21 = (int16)svgen_pwm24_1.Tb_1; // logpar.log22 = (int16)svgen_pwm24_1.Tc_0; // logpar.log23 = (int16)svgen_pwm24_1.Tc_1; //23 logsdata.logs[21] = (int16)(_IQtoIQ14(edrk.iq_power_kw_full_znak));// edrk.from_uom.iq_level_value_kwt //(int16) _IQtoIQ15(rotor_22220.iqFdirty); // logsdata.logs[22] = (int16) _IQtoIQ15(WRotor.iqWRotorSumFilter2); logsdata.logs[23] = (int16) _IQtoIQ15(WRotor.iqWRotorSumFilter);//WRotor.iqWRotorSumFilter WRotor.iqWRotorSum logsdata.logs[24] = (int16) _IQtoIQ15(simple_scalar1.iq_decr_mzz_power);//WRotor.iqWRotorSumFilter2 WRotor.iqWRotorSumFilter3 logsdata.logs[25] = (int16) edrk.from_uom.level_value;// (int16) _IQtoIQ15(WRotor.iqWRotorSumFilter); // logpar.log25 = (int16) _IQtoIQ15(WRotor.iqWRotorSumFilter); // logsdata.logs[25] = (int16) _IQtoIQ15(WRotor.iqWRotorSum); logsdata.logs[26] = (int16) edrk.power_limit.all;//_IQtoIQ15(pll1.vars.pll_Uq); logsdata.logs[27] = (int16)(_IQtoIQ14(edrk.zadanie.iq_limit_power_zad));//(int16) _IQtoIQ15(pll1.vars.pll_Ud);//28 logsdata.logs[28] = (int16) _IQtoIQ12(edrk.master_theta);//29 logsdata.logs[29] = (int16) _IQtoIQ15(edrk.master_Uzad);//30 logsdata.logs[30] = (int16) _IQtoIQ14(edrk.f_stator); logsdata.logs[31] = (int16) _IQtoIQ12(edrk.k_stator1); logsdata.logs[32] = optical_read_data.data.cmd.all; logsdata.logs[33] = optical_read_data.data.pzad_or_wzad; logsdata.logs[34] = optical_read_data.data.angle_pwm; logsdata.logs[35] = optical_read_data.data.iq_zad_i_zad; logsdata.logs[36] = optical_write_data.data.cmd.all; logsdata.logs[37] = optical_write_data.data.angle_pwm; logsdata.logs[38] = optical_write_data.data.pzad_or_wzad; logsdata.logs[39] = optical_write_data.data.iq_zad_i_zad; ///////////// logsdata.logs[40] = (int16)(_IQtoIQ15(simple_scalar1.Izad)); logsdata.logs[41] = (int16)(_IQtoIQ15(simple_scalar1.mzz_zad_in2));//(int16)(_IQtoIQ15(Uze_t1)); logsdata.logs[42] = (int16)(_IQtoIQ15(simple_scalar1.pidF.OutMax)); logsdata.logs[43] = (int16)(_IQtoIQ15(simple_scalar1.mzz_zad_int)); logsdata.logs[44] = (int16)(_IQtoIQ15(simple_scalar1.Izad_from_master)); logsdata.logs[45] = (int16)(_IQtoIQ14(simple_scalar1.pidF.Fdb)); logsdata.logs[46] = (int16)(_IQtoIQ14(simple_scalar1.pidF.Ref)); logsdata.logs[47] = (int16)(_IQtoIQ14(simple_scalar1.pidF.Ui)); logsdata.logs[48] = (int16)(_IQtoIQ14(simple_scalar1.pidF.Up)); logsdata.logs[49] = (int16)(_IQtoIQ14(simple_scalar1.pidF.SatErr)); logsdata.logs[50] = (int16)(_IQtoIQ14(simple_scalar1.pidF.Out)); logsdata.logs[51] = (int16)(_IQtoIQ14(simple_scalar1.pidPower.Fdb)); logsdata.logs[52] = (int16)(_IQtoIQ14(simple_scalar1.pidPower.Ref)); logsdata.logs[53] = (int16)(_IQtoIQ14(simple_scalar1.pidPower.Ui)); logsdata.logs[54] = (int16)(_IQtoIQ14(simple_scalar1.pidPower.Up)); logsdata.logs[55] = (int16)(_IQtoIQ14(simple_scalar1.pidPower.SatErr)); logsdata.logs[56] = (int16)(_IQtoIQ14(simple_scalar1.pidPower.Out)); logsdata.logs[57] = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.Fdb)); logsdata.logs[58] = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.Ref)); logsdata.logs[59] = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.Ui)); logsdata.logs[60] = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.Up)); logsdata.logs[61] = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.SatErr)); logsdata.logs[62] = (int16)(_IQtoIQ15(simple_scalar1.pidIm1.Out)); logsdata.logs[63] = (int16)(_IQtoIQ12(simple_scalar1.Uze_t1)); logsdata.logs[64] = (int16)(_IQtoIQ15(simple_scalar1.bpsi_curent)); logsdata.logs[65] = (int16)(_IQtoIQ14(simple_scalar1.iqKoefOgran)); logsdata.logs[66] = (int16)(_IQtoIQ14(simple_scalar1.Fz)); logsdata.logs[67] = (int16) (_IQtoIQ15(simple_scalar1.iq_decr_mzz_power_filter));//rotor_22220.direct_rotor logsdata.logs[68] = (int16)(_IQtoIQ14(simple_scalar1.pidF.OutMin));//(int16)edrk.Status_Sbor; logsdata.logs[69] = (int16)(_IQtoIQ14(simple_scalar1.pidPower.OutMax));//(int16)edrk.Stage_Sbor; logsdata.logs[70] = (int16)(_IQtoIQ14(filter.iqUin_m1));//(int16)edrk.Sbor_Mode; logsdata.logs[71] = (int16)edrk.from_shema.all; logsdata.logs[72] = (int16)(_IQtoIQ15(simple_scalar1.iqKoefOgranIzad));//(int16)edrk.from_shema_filter.all; // logsdata.logs[73] = (int16)(_IQtoIQ14(filter.iqUin_m2));//simple_scalar1.direction; logsdata.logs[74] = (int16)(_IQtoIQ14(edrk.iq_power_kw_full_filter_znak));// logsdata.logs[75] = (int16)(_IQtoIQ15(edrk.iq_freq_50hz));//edrk.iq_freq_50hz logsdata.logs[76] = (int16)(_IQtoIQ15(simple_scalar1.mzz_zad_in1)); // can regs // logsdata.logs[77] = (int16)(((unsigned long)edrk.canes_reg >> 16) & 0x1ff); // logsdata.logs[78] = (int16)((unsigned long)edrk.canes_reg & 0x3f); // // logsdata.logs[79] = (int16)(edrk.cantec_reg & 0xff); // logsdata.logs[80] = (int16)(edrk.canrec_reg & 0xff); logsdata.logs[77] = (int16)(_IQtoIQ14(uf_alg.Ud)); logsdata.logs[78] = (int16)(_IQtoIQ14(uf_alg.Uq)); logsdata.logs[79] = (int16)(_IQtoIQ14(edrk.all_limit_koeffs.uom_limit));//edrk.MasterSlave; logsdata.logs[80] = (int16)(_IQtoIQ14(edrk.Kplus)); // logsdata.logs[65] = (int16)(_IQtoIQ14(edrk.all_limit_koeffs.temper_limit)); logsdata.logs[81] = (int16)(_IQtoIQ14(edrk.all_limit_koeffs.uin_freq_limit)); logsdata.logs[82] = (int16)(_IQtoIQ14(uf_alg.svgen_dq_Ta)); logsdata.logs[83] = (int16)(_IQtoIQ14(uf_alg.svgen_dq_Tb)); logsdata.logs[84] = (int16)(_IQtoIQ14(uf_alg.svgen_dq_Tc)); // uf_alg.tetta_bs // logsdata.logs[64] = (int16)(_IQtoIQ15()); // logsdata.logs[64] = (int16)(_IQtoIQ15()); logsdata.logs[85] = edrk.from_uom.digital_line.all; // logsdata.logs[75] = edrk.errors.e2.all; // logsdata.logs[76] = edrk.errors.e3.all; // logsdata.logs[77] = edrk.errors.e4.all; // logsdata.logs[78] = edrk.errors.e5.all; // logsdata.logs[79] = edrk.errors.e6.all; // logsdata.logs[80] = edrk.errors.e7.all; // // logsdata.logs[67] = (int16) _IQtoIQ15(WRotor.iqWRotorCalcBeforeRegul1); // logsdata.logs[68] = (int16) _IQtoIQ15(WRotor.iqWRotorCalcBeforeRegul2); // logsdata.logs[69] = (int16) _IQtoIQ15(WRotor.iqWRotorCalc1); // logsdata.logs[24] = (int16) _IQtoIQ15(WRotor.iqWRotorCalc2); // logsdata.logs[70] = (int16) _IQtoIQ15(WRotor.iqWRotorSumRamp); // logsdata.logs[72] = (int16) (WRotorPBus.RotorDirectionSlow); // logsdata.logs[73] = (int16) (WRotorPBus.RotorDirectionSlow2); // logsdata.logs[74] = (int16) (WRotorPBus.RotorDirectionInstant); //(int16) (WRotorPBus.); // logsdata.logs[75] = (int16) (WRotor.iqTimeSensor1); // logsdata.logs[76] = (int16) (WRotor.iqTimeSensor2); // // logsdata.logs[77] = (int16) _IQtoIQ15(WRotor.iqWRotorCalc1Ramp); // logsdata.logs[78] = (int16) _IQtoIQ15(WRotor.iqWRotorCalc2Ramp); // // logsdata.logs[79] = (int16) _IQtoIQ15(WRotor.iqPrevWRotorCalc1); // logsdata.logs[80] = (int16) _IQtoIQ15(WRotor.iqPrevWRotorCalc2); // logsdata.logs[81] = (int16) modbus_table_can_in[124].all;//Обороты (заданные); // logsdata.logs[82] = (int16) modbus_table_can_in[134].all;//запас мощности // logsdata.logs[83] = (int16) modbus_table_can_in[125].all;//Мощность (заданная) // // logsdata.logs[84] = (int16) project.cds_in[0].read.pbus.data_in.all; // logsdata.logs[85] = (int16) project.cds_in[1].read.pbus.data_in.all; logsdata.logs[86] = (int16) _IQtoIQ15(vect_control.iqId1); logsdata.logs[87] = (int16) _IQtoIQ15(vect_control.iqIq1); logsdata.logs[88] = (int16) _IQtoIQ15(vect_control.iqId2); logsdata.logs[89] = (int16) _IQtoIQ15(vect_control.iqIq2); logsdata.logs[90] = 0; return 90; } ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// #define PAUSE_SLOW_LOG 20 void save_slow_logs(int run, int t_slow) { static int c_step=0; // static int c_all = (FREQ_PWM>>2); // Раз в 0,125 с static int c_all = (FREQ_PWM>>1); // Раз в 0,250 с static int prev_run=0; static unsigned int c_pause=0; if (rs_a.RS_PrevCmd==CMD_RS232_UPLOAD) return; if (run==0 && c_pause>=PAUSE_SLOW_LOG) return; c_all = (FREQ_PWM>>(1+t_slow)); if (c_all<2) c_all = 2; if (c_step>=c_all) { test_mem_limit(SLOW_LOG, 1); // prepare_data_to_logs(); getSlowLogs(1); c_step = 0; if (run==1) c_pause = 0; else { if (c_pause= 1)//1 { count_step_run++; // i_led1_on_off(1); // write_to_mem(FAST_LOG, (int16)count_step_run); getFastLogs(!f.Ciclelog); // for (i_log=0;i_log<72;i_log++) // write_to_mem(FAST_LOG, (int16) logsdata.logs[i_log]); // write_to_mem(FAST_LOG, (int16) logpar.log85); // if (logpar.start_write_fast_log) { // get_log_params_count(); // logpar.start_write_fast_log = 0; // } count_step = 0; } } else { if (f.Stop && log_params.log_saved_to_const_mem == 0) { log_params.copy_log_to_const_memory = 1; log_params.log_saved_to_const_mem = 1; f.flag_send_alarm_log_to_MPU = 1; } } #if(_ENABLE_PWM_LINES_FOR_TESTS_PWM) PWM_LINES_TK_23_OFF; #endif if (filter.iqU_1_long>edrk.iqMIN_U_ZPT || filter.iqU_2_long>edrk.iqMIN_U_ZPT) local_enable_slow_log = 1; else local_enable_slow_log = 0; if (edrk.stop_logs_rs232 == 0 && edrk.stop_slow_log ==0 && log_to_HMI.send_log == 0) save_slow_logs(edrk.Go || (local_enable_slow_log && edrk.Status_Ready.bits.ready_final==0), edrk.t_slow_log); } //////////////////////////////////////////////////////////////////