matlab_23550/Inu/Src/main/temper_p_tools.c
2024-12-27 10:50:32 +03:00

78 lines
2.2 KiB
C

/*
* temper_p_tools.c
*
* Created on: 13 íîÿá. 2024 ã.
* Author: Evgeniy_Sokolov
*/
#include <edrk_main.h>
#include <params.h>
#include <params_alg.h>
#include <params_norma.h>
#include <params_pwm24.h>
#include <params_temper_p.h>
#include <project.h>
#include "IQmathLib.h"
#include "mathlib.h"
#include "adc_tools.h"
#include "temper_p_tools.h"
///////////////////////////////////////////////
void nagrev_auto_on_off(void)
{
//min_real_int_temper_air
// if (edrk.temper_edrk.max_real_int_temper_water<TEMPER_NAGREF_ON)
// edrk.to_ing.bits.NAGREV_OFF = 0;
//
// if (edrk.temper_edrk.max_real_int_temper_water>TEMPER_NAGREF_OFF)
// edrk.to_ing.bits.NAGREV_OFF = 1;
if (edrk.temper_edrk.min_real_int_temper_air<TEMPER_NAGREF_ON_1 && edrk.temper_edrk.max_real_int_temper_air<TEMPER_NAGREF_ON_2)
edrk.to_ing.bits.NAGREV_OFF = 0;
if (edrk.temper_edrk.min_real_int_temper_air>TEMPER_NAGREF_OFF_1 || edrk.temper_edrk.max_real_int_temper_air>TEMPER_NAGREF_OFF_2)
edrk.to_ing.bits.NAGREV_OFF = 1;
}
///////////////////////////////////////////////
//#define koef_P_Water_filter 1600000 //0.095367431640625
void calc_p_water_edrk(void)
{
_iq iqtain,iq_temp;
static _iq koef_P_Water_filter = _IQ (0.1/2.0); // 5 ñåê ôèëüòð
edrk.p_water_edrk.adc_p_water[0] = ADC_f[1][14];
edrk.p_water_edrk.real_p_water[0] = (_IQtoF(analog.P_Water_internal) * NORMA_ACP_P - 4.0) / 1.6;
edrk.p_water_edrk.real_int_p_water[0] = edrk.p_water_edrk.real_p_water[0] * K_P_WATER_TO_SVU;
iqtain = _IQ(edrk.p_water_edrk.real_p_water[0]/100.0);
iq_temp = _IQ(edrk.p_water_edrk.filter_real_p_water[0]/100.0);
if (edrk.p_water_edrk.flag_init_filter_temp[0]==0)
{
iq_temp = iqtain;
edrk.p_water_edrk.flag_init_filter_temp[0]=1;
}
// iq_temp_engine[i] = exp_regul_iq(koef_Temper_ENGINE_filter, iq_temp_engine[i], iqtain);
iq_temp += _IQmpy( (iqtain-iq_temp), koef_P_Water_filter);
edrk.p_water_edrk.filter_real_p_water[0] = _IQtoF(iq_temp)*100.0;
edrk.p_water_edrk.filter_real_int_p_water[0] = edrk.p_water_edrk.filter_real_p_water[0]*K_P_WATER_TO_SVU;
}
//////////////////////////////////////////////////////////