#include <281xEvTimersInit.h> #include #include #include #include #include #include #include #include #include #include #include //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "mathlib.h" #include "params_hwp.h" //#include "modbus_fill_table.h" #include "big_dsp_module.h" #include "control_station.h" #include "CAN_Setup.h" #include "global_time.h" #include "IQmathLib.h" #include "mathlib.h" #include "modbus_table_v2.h" #include "oscil_can.h" #include "DSP281x_Examples.h" // DSP281x Examples Include File #include "DSP281x_SWPrioritizedIsrLevels.h" // DSP281x Examples Include File #include "DSP281x_Device.h" #include "alg_pll.h" #include "vector_control.h" #include "CRC_Functions.h" #include "RS_Functions.h" #include "xp_project.h" #include "sbor_shema.h" #include "alarm_log_can.h" #include "pwm_test_lines.h" #include "master_slave.h" #include "xp_write_xpwm_time.h" #include "v_rotor_22220.h" #include "log_to_memory.h" #include "log_params.h" #include "build_version.h" #include "profile_interrupt.h" #include "limit_power.h" #include "pwm_logs.h" #include "logs_hmi.h" #include "alarm_log.h" #include "can_protocol_ukss.h" #include "ukss_tools.h" #include "another_bs.h" #include "temper_p_tools.h" #include "digital_filters.h" #include "pll_tools.h" #include "ramp_zadanie_tools.h" #include "uom_tools.h" #include "synhro_tools.h" #if (_SIMULATE_AC==1) #include "sim_model.h" #endif /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// //#pragma DATA_SECTION(ccc, ".slow_vars") //int ccc[40] = {0,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1}; #pragma DATA_SECTION(f, ".slow_vars") FLAG f = FLAG_DEFAULTS; int cur1=0; int cur2=0; unsigned int old_time_edrk1 = 0, old_time_edrk2 = 0, prev_flag_special_mode_rs = 0; #pragma DATA_SECTION(edrk, ".slow_vars") EDRK edrk = EDRK_DEFAULT; //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // задание оборотов от Задатчика PLUS, MINUS // если выбран нужный режим //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// void set_oborots_from_zadat4ik(void) { static unsigned int old_time_edrk3 = 0, prev_PROVOROT; if (!(detect_pause_milisec(100,&old_time_edrk3))) return; } ////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // считываем цифровые входы //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// #define RASCEPITEL_MANUAL_ALWAYS_ON_2 1 // 1 #define TIME_ON_OFF_FOR_IMITATION_RASCEPITEL 50 // 5 сек. #define TIME_FILTER_UMP_SIGNALS 5 // 0.5 сек #define TIME_FILTER_ALL_SIGNALS 5 // 0.5 сек #pragma DATA_SECTION(count_wait_filter, ".slow_vars") unsigned int count_wait_filter[16] = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0}; unsigned int counter_imit_rascepitel = 0; void update_input_edrk(void) { static unsigned int flag_imit_rascepitel = 0; static int st1=0; // ANOTHER PCH edrk.from_second_pch.bits.RASCEPITEL = !FROM_ING_ANOTHER_RASCEPITEL; edrk.from_second_pch.bits.MASTER = FROM_ING_ANOTHER_MASTER_PCH; // ING #if (_FLOOR6==1) if (st1==0) { edrk.from_zadat4ik.all = 0; edrk.from_vpu.all = 0; edrk.from_ing1.bits.ALL_KNOPKA_AVARIA = 0;//!FROM_ALL_KNOPKA_AVARIA; edrk.from_ing1.bits.BLOCK_IZOL_AVARIA = 0;//!FROM_ING_BLOCK_IZOL_AVARIA; edrk.from_ing1.bits.BLOCK_IZOL_NORMA = 1;//!FROM_ING_BLOCK_IZOL_NORMA; edrk.from_ing1.bits.LOCAL_REMOUTE = 1;//0;//!FROM_ING_LOCAL_REMOUTE; edrk.from_ing1.bits.NAGREV_ON = 1;//!FROM_ING_NAGREV_ON; edrk.from_ing1.bits.NASOS_NORMA = 1;//!FROM_ING_NASOS_NORMA; edrk.from_ing1.bits.NASOS_ON = 0;//!FROM_ING_NASOS_ON; edrk.from_ing1.bits.OHLAD_UTE4KA_WATER = 0;//!FROM_ING_OHLAD_UTE4KA_WATER; edrk.from_ing1.bits.UPC_24V_NORMA = 1;//!FROM_ING_UPC_24V_NORMA; edrk.from_ing1.bits.OP_PIT_NORMA = 1;//!FROM_ING_OP_PIT_NORMA; edrk.from_ing1.bits.VENTIL_ON = 0;//!FROM_ING_VENTIL_ON; edrk.from_ing1.bits.VIPR_PREDOHR_NORMA = 1;//!FROM_ING_VIPR_PREDOHR_NORMA; edrk.from_ing1.bits.ZARYAD_ON = 0;//!FROM_ING_ZARYAD_ON; edrk.from_ing1.bits.ZAZEML_OFF = 1;//!FROM_ING_ZAZEML_OFF; edrk.from_ing1.bits.ZAZEML_ON = 0;//!FROM_ING_ZAZEML_ON; edrk.from_ing2.bits.KEY_MINUS = 0;//FROM_ING_OBOROTS_MINUS; edrk.from_ing2.bits.KEY_PLUS = 0;//!FROM_ING_OBOROTS_PLUS; edrk.from_ing2.bits.KEY_KVITIR = 0;//FROM_ING_LOCAL_KVITIR; edrk.from_ing2.bits.KEY_SBOR = 0;//FROM_ING_SBOR_SHEMA; edrk.from_ing2.bits.KEY_RAZBOR = 0;//FROM_ING_RAZBOR_SHEMA; // edrk.from_ing1.bits.RASCEPITEL_ON = 0;//FROM_ING_RASCEPITEL_ON_OFF; // edrk.from_ing2.bits.SOST_ZAMKA = !edrk.to_ing.bits.BLOCK_KEY_OFF;//1;//!FROM_ING_SOST_ZAMKA; // SHEMA edrk.from_shema.bits.RAZBOR_SHEMA = 0;//FROM_BSU_RAZBOR_SHEMA; edrk.from_shema.bits.SBOR_SHEMA = 0;//FROM_BSU_SBOR_SHEMA; edrk.from_shema.bits.ZADA_DISPLAY = 0;//!FROM_BSU_ZADA_DISPLAY; edrk.from_shema.bits.SVU = 0;//!FROM_BSU_SVU; // edrk.from_shema.bits.KNOPKA_AVARIA = FROM_ALL_KNOPKA_AVARIA; edrk.from_shema.bits.QTV_ON_OFF = 0;//!FROM_SHEMA_QTV_ON_OFF; edrk.from_shema.bits.UMP_ON_OFF = 0;//!FROM_SHEMA_UMP_ON_OFF; edrk.from_shema.bits.READY_UMP = 1;//!FROM_SHEMA_READY_UMP; edrk.from_shema.bits.SVU_BLOCK_QTV = 0;//!FROM_SVU_BLOCK_QTV; st1 = 1; } // имитация расцепителя if (edrk.to_ing.bits.RASCEPITEL_ON) flag_imit_rascepitel = 1; if (edrk.to_ing.bits.RASCEPITEL_OFF) flag_imit_rascepitel = 0; edrk.from_ing1.bits.RASCEPITEL_ON = imit_signals_rascepitel(&counter_imit_rascepitel, TIME_ON_OFF_FOR_IMITATION_RASCEPITEL, flag_imit_rascepitel, 0); ///// edrk.from_ing2.bits.SOST_ZAMKA = !edrk.to_ing.bits.BLOCK_KEY_OFF; if (edrk.to_ing.bits.NASOS_2_ON || edrk.to_ing.bits.NASOS_1_ON) { edrk.from_ing1.bits.VENTIL_ON = 1; edrk.from_ing1.bits.NASOS_ON = 1; } else { edrk.from_ing1.bits.VENTIL_ON = 0; edrk.from_ing1.bits.NASOS_ON = 0; } #else // ZADAT4IK if (control_station.alive_control_station[CONTROL_STATION_ZADATCHIK_CAN]) edrk.from_zadat4ik.all = Unites[ZADATCHIK_CAN][16]; else edrk.from_zadat4ik.all = 0; if (control_station.alive_control_station[CONTROL_STATION_VPU_CAN]) edrk.from_vpu.all = Unites[VPU_CAN][16]; else edrk.from_vpu.all = 0; edrk.from_ing1.bits.ALL_KNOPKA_AVARIA = !FROM_ALL_KNOPKA_AVARIA; edrk.from_ing1.bits.BLOCK_IZOL_AVARIA = !FROM_ING_BLOCK_IZOL_AVARIA; edrk.from_ing1.bits.BLOCK_IZOL_NORMA = !FROM_ING_BLOCK_IZOL_NORMA; edrk.from_ing1.bits.LOCAL_REMOUTE = !FROM_ING_LOCAL_REMOUTE; edrk.from_ing1.bits.NAGREV_ON = !FROM_ING_NAGREV_ON; edrk.from_ing1.bits.NASOS_NORMA = !FROM_ING_NASOS_NORMA; edrk.from_ing1.bits.NASOS_ON = !FROM_ING_NASOS_ON; edrk.from_ing1.bits.OHLAD_UTE4KA_WATER = !FROM_ING_OHLAD_UTE4KA_WATER; edrk.from_ing1.bits.UPC_24V_NORMA = !FROM_ING_UPC_24V_NORMA; edrk.from_ing1.bits.OP_PIT_NORMA = !FROM_ING_OP_PIT_NORMA; edrk.from_ing1.bits.VENTIL_ON = !FROM_ING_VENTIL_ON; edrk.from_ing1.bits.VIPR_PREDOHR_NORMA = !FROM_ING_VIPR_PREDOHR_NORMA; edrk.from_ing1.bits.ZARYAD_ON = !FROM_ING_ZARYAD_ON; edrk.from_ing1.bits.ZAZEML_OFF = !FROM_ING_ZAZEML_OFF; edrk.from_ing1.bits.ZAZEML_ON = !FROM_ING_ZAZEML_ON; edrk.from_ing2.bits.KEY_MINUS = FROM_ING_OBOROTS_MINUS; edrk.from_ing2.bits.KEY_PLUS = !FROM_ING_OBOROTS_PLUS; edrk.from_ing2.bits.KEY_KVITIR = FROM_ING_LOCAL_KVITIR; edrk.from_ing2.bits.KEY_SBOR = FROM_ING_SBOR_SHEMA; edrk.from_ing2.bits.KEY_RAZBOR = FROM_ING_RAZBOR_SHEMA; #if(RASCEPITEL_MANUAL_ALWAYS_ON_2) // имитация расцепителя if (edrk.to_ing.bits.RASCEPITEL_ON) flag_imit_rascepitel = 1; if (edrk.to_ing.bits.RASCEPITEL_OFF) flag_imit_rascepitel = 0; edrk.from_ing1.bits.RASCEPITEL_ON = imit_signals_rascepitel(&counter_imit_rascepitel, TIME_ON_OFF_FOR_IMITATION_RASCEPITEL, flag_imit_rascepitel, 0); #else edrk.from_ing1.bits.RASCEPITEL_ON = FROM_ING_RASCEPITEL_ON_OFF; #endif edrk.from_ing2.bits.SOST_ZAMKA = !FROM_ING_SOST_ZAMKA; // SHEMA edrk.from_shema.bits.RAZBOR_SHEMA = FROM_BSU_RAZBOR_SHEMA; edrk.from_shema.bits.SBOR_SHEMA = FROM_BSU_SBOR_SHEMA; if (edrk.from_shema.bits.RAZBOR_SHEMA==1 && edrk.from_shema.bits.SBOR_SHEMA) { // защита от замыкания и одновременного нажатия edrk.from_shema.bits.RAZBOR_SHEMA = 0; edrk.from_shema.bits.SBOR_SHEMA = 0; } edrk.from_shema_filter.bits.RAZBOR_SHEMA = filter_digital_input( edrk.from_shema_filter.bits.RAZBOR_SHEMA, &count_wait_filter[0], TIME_FILTER_ALL_SIGNALS, edrk.from_shema.bits.RAZBOR_SHEMA); edrk.from_shema_filter.bits.SBOR_SHEMA = filter_digital_input( edrk.from_shema_filter.bits.SBOR_SHEMA, &count_wait_filter[1], TIME_FILTER_ALL_SIGNALS, edrk.from_shema.bits.SBOR_SHEMA); edrk.from_shema.bits.ZADA_DISPLAY = !FROM_BSU_ZADA_DISPLAY; edrk.from_shema_filter.bits.ZADA_DISPLAY = filter_digital_input( edrk.from_shema_filter.bits.ZADA_DISPLAY, &count_wait_filter[2], TIME_FILTER_ALL_SIGNALS, edrk.from_shema.bits.ZADA_DISPLAY); edrk.from_shema.bits.SVU = !FROM_BSU_SVU; edrk.from_shema_filter.bits.SVU = filter_digital_input( edrk.from_shema_filter.bits.SVU, &count_wait_filter[3], TIME_FILTER_ALL_SIGNALS, edrk.from_shema.bits.SVU); // edrk.from_shema.bits.KNOPKA_AVARIA = FROM_ALL_KNOPKA_AVARIA; edrk.from_shema.bits.QTV_ON_OFF = !FROM_SHEMA_QTV_ON_OFF; edrk.from_shema_filter.bits.QTV_ON_OFF = filter_digital_input( edrk.from_shema_filter.bits.QTV_ON_OFF, &count_wait_filter[4], TIME_FILTER_ALL_SIGNALS, edrk.from_shema.bits.QTV_ON_OFF); /// фильтрация FROM_SHEMA_UMP_ON_OFF // edrk.local_ump_on_off = !FROM_SHEMA_UMP_ON_OFF; // // if (edrk.local_ump_on_off) // { // if (edrk.local_ump_on_off_count>=TIME_FILTER_UMP_SIGNALS) // edrk.from_shema.bits.UMP_ON_OFF = 1; // else // edrk.local_ump_on_off_count++; // } // else // { // if (edrk.local_ump_on_off_count==0) // edrk.from_shema.bits.UMP_ON_OFF = 0; // else // edrk.local_ump_on_off_count--; // } // // edrk.from_shema.bits.UMP_ON_OFF = !FROM_SHEMA_UMP_ON_OFF; edrk.from_shema_filter.bits.UMP_ON_OFF = filter_digital_input( edrk.from_shema_filter.bits.UMP_ON_OFF, &count_wait_filter[5], TIME_FILTER_UMP_SIGNALS, edrk.from_shema.bits.UMP_ON_OFF); /// фильтрация FROM_SHEMA_READY_UMP // edrk.local_ready_ump = !FROM_SHEMA_READY_UMP; // // if (edrk.local_ready_ump) // { // if (edrk.local_ready_ump_count>=TIME_FILTER_UMP_SIGNALS) // edrk.from_shema.bits.READY_UMP = 1; // else // edrk.local_ready_ump_count++; // } // else // { // if (edrk.local_ready_ump_count==0) // edrk.from_shema.bits.READY_UMP = 0; // else // edrk.local_ready_ump_count--; // } // edrk.from_shema.bits.READY_UMP = !FROM_SHEMA_READY_UMP; edrk.from_shema_filter.bits.READY_UMP = filter_digital_input( edrk.from_shema_filter.bits.READY_UMP, &count_wait_filter[6], TIME_FILTER_UMP_SIGNALS, edrk.from_shema.bits.READY_UMP); edrk.from_shema.bits.SVU_BLOCK_QTV = !FROM_SVU_BLOCK_QTV; edrk.from_shema_filter.bits.SVU_BLOCK_QTV = filter_digital_input( edrk.from_shema_filter.bits.SVU_BLOCK_QTV, &count_wait_filter[7], TIME_FILTER_ALL_SIGNALS, edrk.from_shema.bits.SVU_BLOCK_QTV); #endif } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // определение откуда получать задачу на обороты //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// void get_where_oborots(void) { //// if (CAN_timeout[get_real_out_mbox(MPU_TYPE_BOX,0)-1]==0) // if (CAN_timeout[get_real_in_mbox(MPU_TYPE_BOX,0)]==0) // { // edrk.W_from_SVU = modbus_table_can_in[14].all; // edrk.W_from_DISPLAY = modbus_table_can_in[16].all; // } // else // { // edrk.W_from_SVU = 0; // edrk.W_from_DISPLAY = 0; // } // // // // // if (edrk.from_shema.bits.SVU) // { // edrk.W_from_all = edrk.W_from_SVU; // edrk.W_from_ZADAT4IK = edrk.W_from_all; // } // else // { // if (edrk.from_shema.bits.ZADA_DISPLAY) // { // edrk.W_from_all = edrk.W_from_DISPLAY; // edrk.W_from_ZADAT4IK = edrk.W_from_all; // } // else // edrk.W_from_all = edrk.W_from_ZADAT4IK; // } } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// unsigned int toggle_status_lamp(unsigned int bb1, unsigned int flag) { if (bb1==1 && flag==0) { return 0; } if (bb1==0 && flag==0) { return 0; } if (bb1==1 && flag==1) { return 0; } if (bb1==0 && flag==1) { return 1; } return 0; } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // записываем цифровые выходы //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// void update_output_edrk(void) { unsigned int b; static unsigned int time_toggle1=0,time_toggle2=0; //to ingetim TO_ING_NAGREV_OFF = !edrk.to_ing.bits.NAGREV_OFF; TO_ING_NASOS_1_ON = !edrk.to_ing.bits.NASOS_1_ON; TO_ING_NASOS_2_ON = !edrk.to_ing.bits.NASOS_2_ON; // TO_ING_RESET_BLOCK_IZOL = !edrk.to_ing.bits.RESET_BLOCK_IZOL; TO_ING_SMALL_LAMPA_AVARIA = edrk.to_ing.bits.SMALL_LAMPA_AVARIA; if (edrk.disable_rascepitel_work) { } else { TO_ING_RASCEPITEL_OFF = !edrk.to_ing.bits.RASCEPITEL_OFF; TO_ING_RASCEPITEL_ON = !edrk.to_ing.bits.RASCEPITEL_ON; } // ANOTHER PCH TO_SECOND_PCH_MASTER = edrk.to_second_pch.bits.MASTER; TO_SECOND_PCH_ALARM = !edrk.to_second_pch.bits.ALARM; //to_shema // //#if (ENABLE_USE_QTV==1) // TO_STEND_QM_ON_INVERS = !edrk.to_shema.bits.QTV_ON; //#endif TO_ING_LAMPA_ZARYAD = !edrk.Status_Ready.bits.Batt; TO_ING_ZARYAD_ON = !edrk.to_ing.bits.ZARYAD_ON; TO_ING_BLOCK_KEY_OFF = !edrk.to_ing.bits.BLOCK_KEY_OFF; #if (MODE_QTV_UPRAVLENIE==1) TO_SHEMA_QTV_ON_OFF = !edrk.to_shema.bits.QTV_ON_OFF; #endif #if (MODE_QTV_UPRAVLENIE==2) TO_SHEMA_QTV_OFF = !edrk.to_shema.bits.QTV_OFF; TO_SHEMA_QTV_ON = !edrk.to_shema.bits.QTV_ON; #endif TO_SHEMA_ENABLE_QTV = !edrk.to_shema.bits.ENABLE_QTV; TO_SHEMA_UMP_ON_OFF = !edrk.to_shema.bits.UMP_ON_OFF; //lamps APL // if (edrk.Sbor)// && edrk.from_ing.bits2.GED_NAMAGNI4EN==0) // { // if (edrk.Status_Ready.bits.ready5==0) // edrk.to_zadat4ik.APL_LAMS0.bits.SBOR_SIL_SHEMA = 1; // else // edrk.to_zadat4ik.APL_LAMS0.bits.SBOR_SIL_SHEMA = 0; // } // else // { // edrk.to_zadat4ik.APL_LAMS0.bits.SBOR_SIL_SHEMA = 0; // } edrk.to_vpu.BIG_LAMS.bits.GOTOV2 = edrk.Status_Ready.bits.ready_final; edrk.to_vpu.BIG_LAMS.bits.PEREGRUZKA = edrk.to_zadat4ik.BIG_LAMS.bits.OGRAN_POWER; edrk.to_vpu.BIG_LAMS.bits.PODDERG_OBOROTS = 0;// edrk.to_vpu.BIG_LAMS.bits.VPU = edrk.to_zadat4ik.APL_LAMS0.bits.OBOROT_VPU; } /////////////////////////////////////////////// /////////////////////////////////////////////// // ОсновнаЯ программа /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// void update_lamp_alarm(void) { if ((edrk.errors.e0.all) || (edrk.errors.e1.all) || (edrk.errors.e2.all) || (edrk.errors.e3.all) || (edrk.errors.e4.all) || (edrk.errors.e5.all) || (edrk.errors.e6.all) || (edrk.errors.e7.all) || (edrk.errors.e8.all) || (edrk.errors.e9.all) || (edrk.errors.e10.all) || (edrk.errors.e11.all) || (edrk.errors.e12.all) ) { edrk.to_ing.bits.SMALL_LAMPA_AVARIA = 1; // edrk.to_second_pch.bits.ALARM = 1; edrk.summ_errors = 1; edrk.Stop |= 1; } else { edrk.to_ing.bits.SMALL_LAMPA_AVARIA = 0; edrk.to_second_pch.bits.ALARM = 0; edrk.summ_errors = 0; } } /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// #define TIME_WAIT_RELE_QTV_ON 30 //2 sec #define TIME_WAIT_RELE_QTV_OFF 30 //2 sec #define TIME_WAIT_ANSWER_QTV_ON TIME_WAIT_ERROR_QTV //150 //15 sec #define TIME_WAIT_ANSWER_QTV_OFF 50 //4 sec /////////////////////////////////////////////// int qtv_on_off(unsigned int flag) { static unsigned int time_wait_rele_on_qtv=0; static unsigned int time_wait_rele_off_qtv=0; static unsigned int time_wait_answer_on_qtv=0; static unsigned int time_wait_answer_off_qtv=0; static unsigned int count_err_on = 0; int cmd_qtv=0;//,cmd_p2=0; static int QTV_Ok = 0; static int prev_error = 0; cmd_qtv = 0; // cmd_p2 = 0; if ( flag==1 && edrk.summ_errors==0) { cmd_qtv = 1; } else { cmd_qtv = 0; } edrk.cmd_to_qtv = cmd_qtv; if (cmd_qtv) { edrk.to_shema.bits.ENABLE_QTV = 1; edrk.to_shema.bits.QTV_OFF = 1; if ((pause_detect_error(&time_wait_rele_on_qtv,TIME_WAIT_RELE_QTV_ON,1)==0) && edrk.from_shema_filter.bits.QTV_ON_OFF==0) { #if (MODE_QTV_UPRAVLENIE==2) edrk.to_shema.bits.QTV_ON = 1; #endif #if (MODE_QTV_UPRAVLENIE==1) edrk.to_shema.bits.QTV_ON_OFF = 1; #endif } else edrk.to_shema.bits.QTV_ON = 0; if (pause_detect_error(&time_wait_answer_on_qtv,TIME_WAIT_ANSWER_QTV_ON,1)==0) { if (edrk.from_shema_filter.bits.QTV_ON_OFF==1) QTV_Ok = 1; } else { // была команда на вкл, но сухой контакт не пришел if (edrk.from_shema_filter.bits.QTV_ON_OFF==0) { #if (WORK_ON_STEND_D) if (pause_detect_error(&count_err_on,TIME_WAIT_ANSWER_QTV_ON,1)) { edrk.errors.e6.bits.QTV_ERROR_NOT_ANSWER |= 1; QTV_Ok = 0; } #else edrk.errors.e6.bits.QTV_ERROR_NOT_ANSWER |= 1; QTV_Ok = 0; #endif } else count_err_on = 0; } time_wait_rele_off_qtv = 0; time_wait_answer_off_qtv = 0; } else { QTV_Ok = 0; edrk.to_shema.bits.ENABLE_QTV = 0; time_wait_rele_on_qtv = 0; time_wait_answer_on_qtv = 0; edrk.to_shema.bits.QTV_ON = 0; edrk.to_shema.bits.QTV_ON_OFF = 0; // if (pause_detect_error(&time_wait_rele_off_qtv,TIME_WAIT_RELE_QTV_OFF,1)==0) // edrk.to_shema.bits.QTV_OFF = 1; // else edrk.to_shema.bits.QTV_OFF = 0; if (pause_detect_error(&time_wait_answer_off_qtv,TIME_WAIT_ANSWER_QTV_OFF,1)==0) { } else { if (edrk.from_shema_filter.bits.QTV_ON_OFF==1) edrk.errors.e6.bits.QTV_ERROR_NOT_ANSWER |= 1; } if (prev_error!=edrk.summ_errors && edrk.summ_errors) { if (pause_detect_error(&time_wait_rele_off_qtv,TIME_WAIT_RELE_QTV_OFF,1)==1) time_wait_rele_off_qtv = 0; } } prev_error = edrk.summ_errors; return (QTV_Ok); } /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// void detect_kvitir_from_all(void) { static int prev_kvitir=0; edrk.Kvitir = control_station.active_array_cmd[CONTROL_STATION_CMD_CHECKBACK] || edrk.from_ing2.bits.KEY_KVITIR || edrk.from_zadat4ik.bits.KVITIR; /* if (edrk.RemouteFromRS) edrk.Kvitir = edrk.KvitirRS; if (edrk.RemouteFromVPU) edrk.Kvitir = edrk.KvitirVPU; if (edrk.RemouteFromDISPLAY) edrk.Kvitir = edrk.from_display.bits.KVITIR;//edrk.KvitirDISPLAY; if (edrk.RemouteFromMPU) edrk.Kvitir = edrk.KvitirMPU; */ if (edrk.Kvitir==1 && prev_kvitir==0) { if (edrk.Status_Ready.bits.ready_final==0 && edrk.Go==0 && edrk.Stop == 1) { edrk.KvitirProcess = 1; project.clear_errors_all_plates(); clear_errors(); edrk.KvitirProcess = 0; } clear_warnings(); /* edrk.KvitirDISPLAY = 0; edrk.KvitirVPU = 0; edrk.KvitirMPU = 0; edrk.KvitirSVU = 0; edrk.KvitirRS = 0; */ } prev_kvitir = edrk.Kvitir; } /////////////////////////////////////////////// unsigned int get_ready_1(void) { unsigned int r1, r2; if (project.cds_in[0].status == component_Ready && project.cds_in[1].status == component_Ready && project.cds_out[0].status == component_Ready && project.cds_tk[0].status == component_Ready && project.cds_tk[1].status == component_Ready && project.cds_tk[2].status == component_Ready && project.cds_tk[3].status == component_Ready && project.adc[0].status == component_Ready && project.adc[1].status == component_Ready && project.hwp[0].status == component_Ready ) r2 = 1; else r2 = 0; r1 = (edrk.ms.ready1 && edrk.from_ing1.bits.NASOS_NORMA && edrk.from_ing1.bits.ZAZEML_ON==0 && edrk.from_ing1.bits.ZAZEML_OFF==1 && edrk.from_ing1.bits.VIPR_PREDOHR_NORMA && edrk.from_ing1.bits.BLOCK_IZOL_NORMA && edrk.from_ing1.bits.OP_PIT_NORMA && edrk.from_ing1.bits.UPC_24V_NORMA && r2); return r1; } /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// void set_zadanie_u_charge(void) { // edrk.ZadanieU_Charge = edrk.ZadanieU_Charge_RS; // edrk.iq_ZadanieU_Charge = _IQ(edrk.ZadanieU_Charge/NORMA_ACP); if (edrk.zadanie.ZadanieU_Charge<=100) { edrk.iqMIN_U_ZPT = _IQ(-50.0/NORMA_ACP); edrk.iqMIN_U_IN = _IQ(-50.0/NORMA_ACP); } else { 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); } if (edrk.zadanie.ZadanieU_ChargeU_D_MAX_ERROR_GLOBAL) edrk.iqMAX_U_ZPT_Global = U_D_MAX_ERROR_GLOBAL; } edrk.iqMAX_U_ZPT = edrk.iqMAX_U_ZPT_Global;//_IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC/NORMA_ACP); edrk.iqMAX_U_IN = _IQ(edrk.zadanie.ZadanieU_Charge*MAX_U_PROC/NORMA_ACP); edrk.zadanie.iq_set_break_level = _IQ(NOMINAL_U_BREAK_LEVEL/NORMA_ACP); } /////////////////////////////////////////////// /////////////////////////////////////////////// // ОсновнаЯ программа /////////////////////////////////////////////// /////////////////////////////////////////////// //////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// #define TIME_WAIT_SBOR_1 1 #define TIME_WAIT_SBOR_2 3 void get_sumsbor_command(void) { static unsigned int prev_SBOR_SHEMA = 0; static unsigned int prev_SBOR_SHEMA_ANOTHER_BS = 0; unsigned int SBOR_SHEMA_ANOTHER_BS = 0; static unsigned int Sbor, first=1, w_sbor = 0, Sbor_f = 0; Sbor = edrk.SumSbor; if (Sbor == 0) edrk.run_razbor_shema = 0; SBOR_SHEMA_ANOTHER_BS = read_cmd_sbor_from_bs(); // есть команда сбор схемы с активного пульта if (edrk.Status_Ready.bits.ImitationReady2==0 && control_station.active_array_cmd[CONTROL_STATION_CMD_CHARGE]==1 && (prev_SBOR_SHEMA==0) && edrk.from_ing1.bits.ALL_KNOPKA_AVARIA==0 && edrk.summ_errors==0 && control_station.active_array_cmd[CONTROL_STATION_CMD_UNCHARGE]==0 ) { Sbor = 1; } if (control_station.active_array_cmd[CONTROL_STATION_CMD_UNCHARGE]==1 // || edrk.from_shema_filter.bits.RAZBOR_SHEMA // подключили разбор по кнопке с ЗО минуя активный пост управления ) { edrk.run_razbor_shema = 1; // Sbor = 0; } if (edrk.StartGEDfromZadanie==0 && edrk.run_razbor_shema) Sbor = 0; // разбор этого БС по разбору другого БС? if (SBOR_SHEMA_ANOTHER_BS==0 && prev_SBOR_SHEMA_ANOTHER_BS==1) { Sbor = 0; } prev_SBOR_SHEMA = control_station.active_array_cmd[CONTROL_STATION_CMD_CHARGE]; prev_SBOR_SHEMA_ANOTHER_BS = SBOR_SHEMA_ANOTHER_BS; // разбор по аварии и кнопке! if (edrk.from_ing1.bits.ALL_KNOPKA_AVARIA || edrk.summ_errors) { Sbor = 0; } if (Sbor) { // if (edrk.flag_second_PCH == 0) // { // if (w_sbor=40) level_go_main = 0; } ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// //#pragma CODE_SECTION(get_start_ged_from_zadanie,".fast_run"); int get_start_ged_from_zadanie(void) { // uf const if (edrk.Mode_ScalarVectorUFConst == ALG_MODE_UF_CONST) { if (edrk.zadanie.iq_fzad_rmp!=0 && edrk.zadanie.iq_kzad_rmp!=0) return 1; else return 0; } else // scalar oborots if (edrk.Mode_ScalarVectorUFConst == ALG_MODE_SCALAR_OBOROTS) { if (edrk.MasterSlave==MODE_SLAVE) { if (edrk.zadanie.iq_Izad_rmp!=0 && edrk.zadanie.iq_limit_power_zad_rmp!=0) return 1; else return 0; } else { if (edrk.zadanie.iq_oborots_zad_hz_rmp!=0 && edrk.zadanie.iq_Izad_rmp!=0 && edrk.zadanie.iq_power_zad_rmp!=0 && edrk.zadanie.iq_limit_power_zad_rmp!=0) return 1; else return 0; } } else // scalar power if (edrk.Mode_ScalarVectorUFConst == ALG_MODE_SCALAR_POWER) { if (edrk.zadanie.iq_oborots_zad_hz_rmp!=0 && edrk.zadanie.iq_Izad_rmp!=0 && edrk.zadanie.iq_power_zad_rmp!=0 && edrk.zadanie.iq_limit_power_zad_rmp!=0) return 1; else return 0; } else // foc oborots if (edrk.Mode_ScalarVectorUFConst == ALG_MODE_FOC_OBOROTS) { if (edrk.zadanie.iq_oborots_zad_hz_rmp!=0 && edrk.zadanie.iq_Izad_rmp!=0 && edrk.zadanie.iq_power_zad_rmp!=0 && edrk.zadanie.iq_limit_power_zad_rmp!=0) return 1; else return 0; } else // foc power if (edrk.Mode_ScalarVectorUFConst == ALG_MODE_FOC_POWER) { if (edrk.zadanie.iq_oborots_zad_hz_rmp!=0 && edrk.zadanie.iq_Izad_rmp!=0 && edrk.zadanie.iq_power_zad_rmp!=0 && edrk.zadanie.iq_limit_power_zad_rmp!=0) return 1; else return 0; } else { return 0; } } ////////////////////////////////////////////////////////// void cross_stend_automats(void) { unsigned int g; edrk.to_shema.bits.CROSS_UMP_ON_OFF = 0; edrk.to_shema.bits.CROSS_QTV_ON_OFF = 0; } #define MAX_ERRORS_DETECT_CHANGE_ACTIVE_CONTROL 50 void check_change_post_upravl(void) { static int prev_active_post_upravl = -1, prev_active_post_upravl_another_bs = -1; int active_post_upravl = -1, active_post_upravl_another_bs = -1; static unsigned int count_err = 0; active_post_upravl = get_code_active_post_upravl(); active_post_upravl_another_bs = edrk.active_post_upravl_another_bs; if (edrk.Status_Ready.bits.ready_final && edrk.Ready2_another_bs) { if ((active_post_upravl_another_bs==0 || active_post_upravl==0) && (active_post_upravl==2 || active_post_upravl_another_bs==2)) { // если какой-то БС в СВУ а другой в МЕСТНОЕ edrk.errors.e9.bits.CHANGE_ACTIVE_CONTROL_TO_LOCAL_FROM_SVU |= filter_err_count(&count_err, MAX_ERRORS_DETECT_CHANGE_ACTIVE_CONTROL, 1, 0); } else count_err = 0; } prev_active_post_upravl = active_post_upravl; prev_active_post_upravl_another_bs = active_post_upravl_another_bs; edrk.active_post_upravl = active_post_upravl; } int get_code_active_post_upravl(void) { if (control_station.active_control_station[CONTROL_STATION_TERMINAL_RS232]) return 3; else if (control_station.active_control_station[CONTROL_STATION_TERMINAL_CAN]) return 4; else if (control_station.active_control_station[CONTROL_STATION_INGETEAM_PULT_RS485])//(edrk.RemouteFromDISPLAY) return 0; else if (control_station.active_control_station[CONTROL_STATION_MPU_KEY_CAN]) return 5; else if (control_station.active_control_station[CONTROL_STATION_ZADATCHIK_CAN]) return 6; else if (control_station.active_control_station[CONTROL_STATION_VPU_CAN]) return 1; else if (control_station.active_control_station[CONTROL_STATION_MPU_SVU_CAN]) return 2; else return 10; //error } #define MAX_COUNT_DETECTS_ZERO_U_ZPT 5 void auto_detect_zero_u_zpt(void) { static unsigned int old_time_u_zpt1=0, count_detects = 0, flag_detect_zero_u_zpt = 0; static _iq prev_uzpt1=0; static _iq prev_uzpt2=0; static _iq delta_u = _IQ(3.0/NORMA_ACP); static _iq minimal_detect_u = _IQ(40.0/NORMA_ACP); if (edrk.SumSbor==0 && flag_detect_zero_u_zpt==0) { // нет сбора, значит можем искать ноль Uzpt if (detect_pause_sec(5,&old_time_u_zpt1)) { if ( filter.iqU_1_long>=minimal_detect_u || filter.iqU_2_long>=minimal_detect_u || (prev_uzpt1-filter.iqU_1_long)>=delta_u || (prev_uzpt2-filter.iqU_2_long)>=delta_u ) { // напряжение еще падает count_detects = 0; } else { if (count_detects=0) { if (local_oborots>max_oborots) local_oborots = max_oborots; } else { if (local_oborots<-max_oborots) local_oborots = -max_oborots; } float_oborots = zad_intensiv(1.0, 1.0, float_oborots, local_oborots); edrk.oborots = float_oborots; edrk.power_kw = edrk.oborots * koef_p3/(edrk.count_bs_work+1); // // max_oborots = edrk.zadanie.limit_power_zad/koef_p2; // max_oborots = my_satur_float(max_oborots,MAX_ZADANIE_OBOROTS_ROTOR,MIN_ZADANIE_OBOROTS_ROTOR, 0); // // local_oborots = fast_round(_IQtoF(edrk.zadanie.rmp_oborots_imitation_rmp)*60.0*NORMA_FROTOR); // if (local_oborots>=0) // { // if (local_oborots>max_oborots) // local_oborots = max_oborots; // } // else // { // if (local_oborots<-max_oborots) // local_oborots = -max_oborots; // } } else { local_power = fast_round(_IQtoF(edrk.zadanie.iq_power_zad_rmp) * NORMA_ACP * NORMA_ACP / 1000.0); if (edrk.count_bs_work==0) local_power = my_satur_float(local_power, MAX_ZADANIE_POWER/2, MIN_ZADANIE_POWER/2, 0); else local_power = my_satur_float(local_power, MAX_ZADANIE_POWER, MIN_ZADANIE_POWER, 0); local_oborots = local_power/koef_p3; float_oborots = zad_intensiv(1.0, 1.0, float_oborots, local_oborots); edrk.oborots = float_oborots; edrk.power_kw = local_power/(edrk.count_bs_work+1);//edrk.oborots * koef_p3; // local_power = fast_round(_IQtoF(edrk.zadanie.iq_power_zad_rmp) * NORMA_ACP * NORMA_ACP / 1000.0); // local_oborots = local_power/koef_p1; } // float_oborots = zad_intensiv(0.5, 0.5, float_oborots, local_oborots); // edrk.oborots = float_oborots; // // if (edrk.oborots>=0) // edrk.power_kw = edrk.oborots * koef_p2; // else // edrk.power_kw = edrk.oborots * koef_p2; // // // // if (edrk.oborots>=0) // edrk.power_kw = edrk.oborots * koef_p; // else // edrk.power_kw = edrk.oborots * (+koef_p); } else { edrk.oborots = fast_round(_IQtoF(WRotor.iqWRotorSumFilter3)*60.0*NORMA_FROTOR); // local_power = fast_round(_IQtoF(filter.PowerScalarFilter2) * NORMA_ACP * NORMA_ACP / 1000.0); // // if (edrk.oborots>=0) // edrk.power_kw = local_power; // else // edrk.power_kw = -local_power; edrk.power_kw = fast_round(_IQtoF(edrk.iq_power_kw_one_filter_znak) * NORMA_ACP * NORMA_ACP / 1000.0); } power_kw_full = edrk.power_kw + edrk.power_kw_another_bs; // if (power_kw_full < MINIMAL_POWER_TO_DISPLAY) // edrk.power_kw_full = 0; // else edrk.power_kw_full = power_kw_full; /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// edrk.Status_Ready.bits.ready1 = get_ready_1(); pump_control(); if (control_station_select_active()) { if (filter_count_error_control_station_select_active<30) filter_count_error_control_station_select_active++; else edrk.errors.e7.bits.NOT_VALID_CONTROL_STATION |= 1; } else filter_count_error_control_station_select_active = 0; edrk.current_active_control = get_current_station_control(); if (edrk.current_active_controlLEVEL_HWP_I_AF) level = LEVEL_HWP_I_AF; if (level<0) level = 0; if (n_af == 0) { if (level != prev_level_all) { i_af_protect_d = convert_real_to_mv_hwp(2,level); if (i_af_protect_d>1500) i_af_protect_d = 1500; // max 1500 mV update_maz_level_i_af(n_af, i_af_protect_d); project.write_all_hwp(); } prev_level_all = level; } // else // { // if (level != prev_level_2) // { // i_af_protect_d = convert_real_to_mv_hwp(4,level); // if (i_af_protect_d>1500) i_af_protect_d = 1500; // max 1500 mV // // update_maz_level_i_af(n_af, i_af_protect_d); // project.write_all_hwp(); // } // prev_level_2 = level; // // } } void calc_count_build_revers(void) { static unsigned int prev_b = 0, prev_r = 0; if (edrk.Status_Ready.bits.ImitationReady2) { detect_work_revers(((edrk.oborots>=0) ? 1 : -1), edrk.zadanie.iq_oborots_zad_hz_rmp, edrk.oborots); } else detect_work_revers(WRotor.RotorDirectionSlow, edrk.zadanie.iq_oborots_zad_hz_rmp, WRotor.iqWRotorSumFilter2); if (edrk.count_revers != prev_r) inc_count_revers(); if (edrk.count_sbor != prev_b) inc_count_build(); prev_r = edrk.count_revers; prev_b = edrk.count_sbor; } void prepare_logger_pult(void) { edrk.pult_data.logger_params[0] = fast_round(_IQtoF(simple_scalar1.iq_decr_mzz_power_filter)*1000.0);//edrk.zadanie.oborots_zad; edrk.pult_data.logger_params[1] = fast_round(_IQtoF(edrk.Kplus)*1000.0); edrk.pult_data.logger_params[2] = fast_round(_IQtoF(pll1.vars.pll_Ud)*NORMA_ACP); edrk.pult_data.logger_params[3] = fast_round(_IQtoF(edrk.f_stator)*NORMA_FROTOR*100.0); edrk.pult_data.logger_params[4] = fast_round(_IQtoF(edrk.k_stator1)*10000.0); edrk.pult_data.logger_params[5] = fast_round(_IQtoF(pll1.vars.pll_Uq)*NORMA_ACP); edrk.pult_data.logger_params[6] = edrk.period_calc_pwm_int2; edrk.pult_data.logger_params[7] = fast_round(_IQtoF(simple_scalar1.pidF.OutMax)*NORMA_ACP);//edrk.power_kw_full; edrk.pult_data.logger_params[8] = edrk.Sbor_Mode; edrk.pult_data.logger_params[9] = edrk.Stage_Sbor; edrk.pult_data.logger_params[10] = fast_round(_IQtoF(edrk.Izad_out)*NORMA_ACP); edrk.pult_data.logger_params[11] = edrk.period_calc_pwm_int1; edrk.pult_data.logger_params[12] = fast_round(_IQtoF(simple_scalar1.pidF.Out)*NORMA_ACP); edrk.pult_data.logger_params[13] = fast_round(_IQtoF(simple_scalar1.pidF.OutMin)*NORMA_ACP); edrk.pult_data.logger_params[14] = fast_round(_IQtoF(simple_scalar1.pidPower.Out)*NORMA_ACP); edrk.pult_data.logger_params[15] = fast_round(_IQtoF(simple_scalar1.pidPower.OutMax)*NORMA_ACP); edrk.pult_data.logger_params[16] = fast_round(_IQtoF(simple_scalar1.pidF.Ref)*NORMA_FROTOR*1000.0);// //modbus_table_can_in[123].all;//Управление (По мощности, По оборотам) edrk.pult_data.logger_params[17] = modbus_table_can_in[124].all;//Обороты (заданные) edrk.pult_data.logger_params[18] = modbus_table_can_in[125].all;//Мощность (заданная) edrk.pult_data.logger_params[19] = modbus_table_can_in[134].all;//запас мощности edrk.pult_data.logger_params[20] = fast_round(_IQtoF(simple_scalar1.bpsi_curent)*NORMA_FROTOR*1000.0); edrk.pult_data.logger_params[21] = fast_round(_IQtoF(edrk.from_uom.iq_level_value_kwt)*NORMA_ACP*NORMA_ACP/1000.0); edrk.pult_data.logger_params[22] = fast_round(_IQtoF(simple_scalar1.iqKoefOgran)*1000.0);//fast_round(_IQtoF(rotor_22220.iqFout)*NORMA_FROTOR*1000.0); edrk.pult_data.logger_params[23] = fast_round(_IQtoF(simple_scalar1.iqKoefOgranIzad)*1000.0); //fast_round(_IQtoF(edrk.zadanie.iq_limit_power_zad)*NORMA_ACP*NORMA_ACP/1000.0); edrk.pult_data.logger_params[24] = fast_round(_IQtoF(edrk.all_limit_koeffs.sum_limit)*1000.0); edrk.pult_data.logger_params[25] = fast_round(_IQtoF(edrk.all_limit_koeffs.uom_limit)*1000.0); edrk.pult_data.logger_params[26] = fast_round(_IQtoF(edrk.all_limit_koeffs.uin_freq_limit)*1000.0); edrk.pult_data.logger_params[27] = fast_round(_IQtoF(simple_scalar1.pidF.Fdb)*NORMA_FROTOR*1000.0); // } int calc_auto_moto_pump(void) { volatile long sum_minutes_pump1, sum_minutes_pump2, set_delta_minutes, cur_delta_minutes; sum_minutes_pump1 = 0; if (edrk.pult_data.data_from_pult.moto[12]>=0) sum_minutes_pump1 += edrk.pult_data.data_from_pult.moto[12] * 1440; if (edrk.pult_data.data_from_pult.moto[3]>=0) sum_minutes_pump1 += edrk.pult_data.data_from_pult.moto[3]; sum_minutes_pump2 = 0; if (edrk.pult_data.data_from_pult.moto[13]>=0) sum_minutes_pump2 += edrk.pult_data.data_from_pult.moto[13] * 1440; if (edrk.pult_data.data_from_pult.moto[4]>=0) sum_minutes_pump2 += edrk.pult_data.data_from_pult.moto[4]; cur_delta_minutes = sum_minutes_pump1 - sum_minutes_pump2; set_delta_minutes = edrk.pult_data.data_to_pult.TimeToChangePump; if (set_delta_minutes==0) { return 0; } if (cur_delta_minutes>set_delta_minutes) { return 2; } else if (cur_delta_minutes<-set_delta_minutes) { return 1; } else if (edrk.pult_data.data_from_pult.LastWorkPump==0) { if (cur_delta_minutes>0) { return 1; } else if (cur_delta_minutes<=0) { return 2; } else return 0; } else { if (edrk.pult_data.data_from_pult.LastWorkPump == 1) return 1; else if (edrk.pult_data.data_from_pult.LastWorkPump == 2) return 2; else return 0; } // // // if (cur_delta_minutes>0) // { // //T1>T2 // if (_IQabs(cur_delta_minutes) >= set_delta_minutes) // { // // T1+delta>T2 // return 2; // } // else // return 1; // } // else // { // //T2>T1 // if (_IQabs(cur_delta_minutes) >= set_delta_minutes) // { // //T2+delta>T1 // return 1; // } // else // return 2; // } // if (_IQabs(cur_delta_minutes) > set_delta_minutes) // { // if (cur_delta_minutes>) // return 2; // else // return 1; // // // } // if (cur_delta_minutes>=0) // { // if (_IQabs(cur_delta_minutes) > set_delta_minutes) // return 2; // else // return 1; // } // else // { // if (_IQabs(cur_delta_minutes) > set_delta_minutes) // return 1; // else // return 2; // } } void read_can_error(void) { EALLOW; edrk.canes_reg = ECanaRegs.CANES.all; edrk.canrec_reg = ECanaRegs.CANREC.all; edrk.cantec_reg = ECanaRegs.CANTEC.all; EDIS; cmd_clear_can_error(); } void clear_can_error(void) { // EALLOW; // ECanaRegs.CANES.all=0xffffffff; InitCanSoft(); //EDIS; } void cmd_clear_can_error(void) { static int prev_cmd_clear_can_error = 0; if (edrk.cmd_clear_can_error && prev_cmd_clear_can_error==0) { clear_can_error(); } prev_cmd_clear_can_error = edrk.cmd_clear_can_error; } void check_temper_break(void) { if ( (edrk.break_tempers[0] > ABNORMAL_TEMPER_BREAK_INT) || (edrk.break_tempers[1] > ABNORMAL_TEMPER_BREAK_INT) || (edrk.break_tempers[2] > ABNORMAL_TEMPER_BREAK_INT) || (edrk.break_tempers[3] > ABNORMAL_TEMPER_BREAK_INT) ) edrk.warnings.e9.bits.BREAK_TEMPER_WARNING = 1; else { if ( (edrk.break_tempers[0] < ABNORMAL_TEMPER_BREAK_INT-DELTA_TEMPER_BREAK_INT) && (edrk.break_tempers[1] < ABNORMAL_TEMPER_BREAK_INT-DELTA_TEMPER_BREAK_INT) && (edrk.break_tempers[2] < ABNORMAL_TEMPER_BREAK_INT-DELTA_TEMPER_BREAK_INT) && (edrk.break_tempers[3] < ABNORMAL_TEMPER_BREAK_INT-DELTA_TEMPER_BREAK_INT) ) edrk.warnings.e9.bits.BREAK_TEMPER_WARNING = 0; } if ( (edrk.break_tempers[0] > ALARM_TEMPER_BREAK_INT) || (edrk.break_tempers[1] > ALARM_TEMPER_BREAK_INT) || (edrk.break_tempers[2] > ALARM_TEMPER_BREAK_INT) || (edrk.break_tempers[3] > ALARM_TEMPER_BREAK_INT) ) edrk.warnings.e9.bits.BREAK_TEMPER_ALARM = 1; else { //DELTA_TEMPER_BREAK_INT if ( (edrk.break_tempers[0] < ALARM_TEMPER_BREAK_INT-DELTA_TEMPER_BREAK_INT) && (edrk.break_tempers[1] < ALARM_TEMPER_BREAK_INT-DELTA_TEMPER_BREAK_INT) && (edrk.break_tempers[2] < ALARM_TEMPER_BREAK_INT-DELTA_TEMPER_BREAK_INT) && (edrk.break_tempers[3] < ALARM_TEMPER_BREAK_INT-DELTA_TEMPER_BREAK_INT) ) edrk.warnings.e9.bits.BREAK_TEMPER_ALARM = 0; } } #define TIME_FILTER_BREAKER_SIGNALS 10 void check_breaker_ged(void) { static unsigned int count_wait_breaker = 0; edrk.warnings.e9.bits.BREAKER_GED_ON = filter_digital_input( edrk.warnings.e9.bits.BREAKER_GED_ON, &count_wait_breaker, TIME_FILTER_BREAKER_SIGNALS, edrk.breaker_on); // if (edrk.breaker_on) // edrk.warnings.e9.bits.BREAKER_GED_ON = 1; // else // edrk.warnings.e9.bits.BREAKER_GED_ON = 0; }