Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of LGstaandart by
ThermoCalc.c@1:f2adcae3d304, 2016-01-30 (annotated)
- Committer:
- igor_v
- Date:
- Sat Jan 30 13:53:19 2016 +0000
- Revision:
- 1:f2adcae3d304
- Parent:
- 0:8ad47e2b6f00
- Child:
- 21:bc8c1cec3da6
123
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 1:f2adcae3d304 | 1 | #include "Global.h" |
igor_v | 0:8ad47e2b6f00 | 2 | |
igor_v | 0:8ad47e2b6f00 | 3 | #define debug |
igor_v | 0:8ad47e2b6f00 | 4 | #define TEMP_AVER_PERIOD 4 // e. number of seconds for average |
igor_v | 0:8ad47e2b6f00 | 5 | int TermoCompens_Sum = 0; |
igor_v | 0:8ad47e2b6f00 | 6 | unsigned int IsHeating; |
igor_v | 0:8ad47e2b6f00 | 7 | //int Tmp_Out[NUM_OF_THERMOSENS]; |
igor_v | 0:8ad47e2b6f00 | 8 | int dThermoHeatDeltaPer_dTermo[TERMO_FUNC_SIZE]; |
igor_v | 0:8ad47e2b6f00 | 9 | int dThermoCoolDeltaPer_dTermo[TERMO_FUNC_SIZE]; |
igor_v | 0:8ad47e2b6f00 | 10 | int dFuncPer_dTermo[TERMO_FUNC_SIZE]; |
igor_v | 0:8ad47e2b6f00 | 11 | int TermoCompDelta; |
igor_v | 1:f2adcae3d304 | 12 | int Temp_Aver; //e. the mean temperature for 1 Sec for T4 sensor //r. ������� ����������� �� 1 ������� ��� ������� T4 |
igor_v | 0:8ad47e2b6f00 | 13 | int TempEvolution = 0; |
igor_v | 1:f2adcae3d304 | 14 | int StartTermoCompens = 0; //e. initial thermocompensation (in XXX seconds after start ) //r. ��������� ���������������� (����� ��� ������ ����� ������) |
igor_v | 0:8ad47e2b6f00 | 15 | |
igor_v | 1:f2adcae3d304 | 16 | extern int WP_reset_heating; //e. voltage of reset at heating //r. ���������� ������ ��� ���������� |
igor_v | 1:f2adcae3d304 | 17 | extern int WP_reset_cooling; //e. voltage of reset at cooling //r. ���������� ������ ��� ���������� |
igor_v | 0:8ad47e2b6f00 | 18 | |
igor_v | 0:8ad47e2b6f00 | 19 | __inline Max_Saturation(unsigned *lvl, unsigned limit) |
igor_v | 0:8ad47e2b6f00 | 20 | { |
igor_v | 0:8ad47e2b6f00 | 21 | if (*lvl>limit) *lvl = limit; |
igor_v | 0:8ad47e2b6f00 | 22 | } |
igor_v | 0:8ad47e2b6f00 | 23 | |
igor_v | 0:8ad47e2b6f00 | 24 | /*{ |
igor_v | 1:f2adcae3d304 | 25 | switch (Device_blk.Str.TermoMode) //e. selecting thermocompensation mode //r. ����� ������ ���������������� |
igor_v | 0:8ad47e2b6f00 | 26 | { |
igor_v | 0:8ad47e2b6f00 | 27 | case TERMO_ON: |
igor_v | 0:8ad47e2b6f00 | 28 | case TERMO_ON_NUMB_OFF: |
igor_v | 0:8ad47e2b6f00 | 29 | |
igor_v | 1:f2adcae3d304 | 30 | TermoCompens_Sum += StartTermoCompens + DynamicDeltaCalc(); //e. accumulation of the value of thermocompensation from request to request //r. ���������� �������� ���������������� �� ������� �� ������� |
igor_v | 0:8ad47e2b6f00 | 31 | |
igor_v | 0:8ad47e2b6f00 | 32 | break; |
igor_v | 0:8ad47e2b6f00 | 33 | |
igor_v | 0:8ad47e2b6f00 | 34 | case TERMO_ON_STATIC_ONLY: |
igor_v | 0:8ad47e2b6f00 | 35 | case TERMO_ON_STATIC_ONLY_NUMB_OFF: |
igor_v | 0:8ad47e2b6f00 | 36 | #if !defined debug_SOI |
igor_v | 1:f2adcae3d304 | 37 | TermoCompens_Sum += StartTermoCompens; //e. accumulation of the value of thermocompensation from request to request //r. ���������� �������� ���������������� �� ������� �� ������� |
igor_v | 0:8ad47e2b6f00 | 38 | #endif |
igor_v | 0:8ad47e2b6f00 | 39 | break; |
igor_v | 0:8ad47e2b6f00 | 40 | |
igor_v | 0:8ad47e2b6f00 | 41 | case TERMO_ON_DYNAMIC_ONLY: |
igor_v | 0:8ad47e2b6f00 | 42 | case TERMO_ON_DYNAMIC_ONLY_NUMB_OFF: |
igor_v | 0:8ad47e2b6f00 | 43 | #if !defined debug_SOI |
igor_v | 1:f2adcae3d304 | 44 | TermoCompens_Sum += DynamicTermoCompens(); //e. accumulation of the value of thermocompensation from request to request //r. ���������� �������� ���������������� �� ������� �� ������� |
igor_v | 0:8ad47e2b6f00 | 45 | #endif |
igor_v | 0:8ad47e2b6f00 | 46 | break; |
igor_v | 0:8ad47e2b6f00 | 47 | |
igor_v | 0:8ad47e2b6f00 | 48 | case TERMO_OFF: |
igor_v | 0:8ad47e2b6f00 | 49 | default: |
igor_v | 1:f2adcae3d304 | 50 | TermoCompens_Sum = 0; //e. thermocompensation is disable, therefore its part is equal to zero //r. ���������������� ���������, ������� �� ����� ����� ���� |
igor_v | 0:8ad47e2b6f00 | 51 | |
igor_v | 0:8ad47e2b6f00 | 52 | } //of thermomode switch |
igor_v | 0:8ad47e2b6f00 | 53 | } */ |
igor_v | 0:8ad47e2b6f00 | 54 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 55 | ** Function name: StaticTermoCompens |
igor_v | 0:8ad47e2b6f00 | 56 | ** |
igor_v | 0:8ad47e2b6f00 | 57 | ** Descriptions: Procedure of |
igor_v | 0:8ad47e2b6f00 | 58 | ** |
igor_v | 0:8ad47e2b6f00 | 59 | ** parameters: None |
igor_v | 0:8ad47e2b6f00 | 60 | ** Returned value: None |
igor_v | 0:8ad47e2b6f00 | 61 | ** |
igor_v | 0:8ad47e2b6f00 | 62 | ******************************************************************************/ |
igor_v | 1:f2adcae3d304 | 63 | int StaticTermoCompens(int temperature) //r. ������ ����������� ������������ ���������������� �� ���� ������ ������� (100 ���) |
igor_v | 0:8ad47e2b6f00 | 64 | { |
igor_v | 0:8ad47e2b6f00 | 65 | |
igor_v | 1:f2adcae3d304 | 66 | float TermoCompens_Curr; //r. �������� ���������������� �� ���� ������ ������� (100 ���) |
igor_v | 0:8ad47e2b6f00 | 67 | |
igor_v | 0:8ad47e2b6f00 | 68 | int i, t; |
igor_v | 0:8ad47e2b6f00 | 69 | |
igor_v | 1:f2adcae3d304 | 70 | //r. ���������� ������ ����������� TSENS_NUMB |
igor_v | 1:f2adcae3d304 | 71 | //r. ��� ����� �������������: T4, ��� ������: T1 |
igor_v | 1:f2adcae3d304 | 72 | //r. � ���������� �������-����������� ���������������� |
igor_v | 0:8ad47e2b6f00 | 73 | |
igor_v | 0:8ad47e2b6f00 | 74 | //r. Tmp_Out[TSENS_NUMB] = 8960; //-2560; //5120; //8000; // -2600; //-5000; |
igor_v | 0:8ad47e2b6f00 | 75 | |
igor_v | 0:8ad47e2b6f00 | 76 | t = temperature; |
igor_v | 0:8ad47e2b6f00 | 77 | if(t > Device_blk.Str.TemperInt[TERMO_FUNC_SIZE - 1]) |
igor_v | 0:8ad47e2b6f00 | 78 | { |
igor_v | 0:8ad47e2b6f00 | 79 | t = Device_blk.Str.TemperInt[TERMO_FUNC_SIZE - 1]; |
igor_v | 0:8ad47e2b6f00 | 80 | } |
igor_v | 0:8ad47e2b6f00 | 81 | |
igor_v | 0:8ad47e2b6f00 | 82 | i = 0; |
igor_v | 0:8ad47e2b6f00 | 83 | while( t > Device_blk.Str.TemperInt[i] ) i++; |
igor_v | 0:8ad47e2b6f00 | 84 | |
igor_v | 0:8ad47e2b6f00 | 85 | //r. Tmp_Out[5] = i; |
igor_v | 0:8ad47e2b6f00 | 86 | TermoCompens_Curr = Device_blk.Str.TermoFunc[i] - dFuncPer_dTermo[i] * (float)( Device_blk.Str.TemperInt[i] - t ); |
igor_v | 0:8ad47e2b6f00 | 87 | |
igor_v | 1:f2adcae3d304 | 88 | //r. ������� |
igor_v | 1:f2adcae3d304 | 89 | //r. TermoCompens_Curr = 1.111111125; // ������� |
igor_v | 1:f2adcae3d304 | 90 | //r.TermoCompens_Curr = // 0.25; // �� 1 ��� ������������� 2500 ��������� |
igor_v | 0:8ad47e2b6f00 | 91 | /*r. |
igor_v | 1:f2adcae3d304 | 92 | //0.000100; // �����., ��� ������� �� 1 ��� ������������� 1 ������� |
igor_v | 1:f2adcae3d304 | 93 | //1.0001; // �����., ��� ������� �� 1 ��� ������������� 10001 ������� |
igor_v | 1:f2adcae3d304 | 94 | // 0.000125; // �����., ��� ������� �� 1 ��� ������������� 1.25 �������� (�� 100 ��������� 122 ���.???) |
igor_v | 1:f2adcae3d304 | 95 | // 0.000105; // �� 100 ��� �.������������� 105 ���., ������. 103??? |
igor_v | 0:8ad47e2b6f00 | 96 | */ |
igor_v | 0:8ad47e2b6f00 | 97 | |
igor_v | 1:f2adcae3d304 | 98 | // TermoCompens_Curr = LONG_2_FRACT_14_18(TermoCompens_Curr); //r. TermoCompens_Curr ��������� � ������ 14.18 |
igor_v | 0:8ad47e2b6f00 | 99 | |
igor_v | 0:8ad47e2b6f00 | 100 | return TermoCompens_Curr; |
igor_v | 0:8ad47e2b6f00 | 101 | } // StaticTermoCompens |
igor_v | 0:8ad47e2b6f00 | 102 | |
igor_v | 0:8ad47e2b6f00 | 103 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 104 | ** Function name: DynamicDeltaCalc |
igor_v | 0:8ad47e2b6f00 | 105 | ** |
igor_v | 0:8ad47e2b6f00 | 106 | ** Descriptions: Procedure of |
igor_v | 0:8ad47e2b6f00 | 107 | ** |
igor_v | 0:8ad47e2b6f00 | 108 | ** parameters: None |
igor_v | 0:8ad47e2b6f00 | 109 | ** Returned value: Thermocompensation addition |
igor_v | 0:8ad47e2b6f00 | 110 | ** |
igor_v | 0:8ad47e2b6f00 | 111 | ******************************************************************************/ |
igor_v | 1:f2adcae3d304 | 112 | int DynamicDeltaCalc() //e. calculation the addition termocompensation for 1 reset //r. ������ ������� ���������������� �� ���� ��������� |
igor_v | 0:8ad47e2b6f00 | 113 | { |
igor_v | 0:8ad47e2b6f00 | 114 | |
igor_v | 0:8ad47e2b6f00 | 115 | int i, t; |
igor_v | 0:8ad47e2b6f00 | 116 | |
igor_v | 0:8ad47e2b6f00 | 117 | t = Temp_Aver; |
igor_v | 0:8ad47e2b6f00 | 118 | |
igor_v | 0:8ad47e2b6f00 | 119 | if (IsHeating) |
igor_v | 0:8ad47e2b6f00 | 120 | { |
igor_v | 0:8ad47e2b6f00 | 121 | if(t > Device_blk.Str.TemperIntDyn[TERMO_FUNC_SIZE - 1]) |
igor_v | 0:8ad47e2b6f00 | 122 | { |
igor_v | 0:8ad47e2b6f00 | 123 | t = Device_blk.Str.TemperIntDyn[TERMO_FUNC_SIZE - 1]; |
igor_v | 0:8ad47e2b6f00 | 124 | } |
igor_v | 0:8ad47e2b6f00 | 125 | |
igor_v | 0:8ad47e2b6f00 | 126 | i = 0; |
igor_v | 0:8ad47e2b6f00 | 127 | while( t > Device_blk.Str.TemperIntDyn[i] ) i++; |
igor_v | 0:8ad47e2b6f00 | 128 | |
igor_v | 0:8ad47e2b6f00 | 129 | TermoCompDelta = ( Device_blk.Str.ThermoHeatDelta[i] - dThermoHeatDeltaPer_dTermo[i] * (float)( Device_blk.Str.TemperIntDyn[i] - t ) ); |
igor_v | 0:8ad47e2b6f00 | 130 | } |
igor_v | 0:8ad47e2b6f00 | 131 | else |
igor_v | 0:8ad47e2b6f00 | 132 | { |
igor_v | 0:8ad47e2b6f00 | 133 | if(t > Device_blk.Str.TemperCoolIntDyn[TERMO_FUNC_SIZE - 1]) |
igor_v | 0:8ad47e2b6f00 | 134 | { |
igor_v | 0:8ad47e2b6f00 | 135 | t = Device_blk.Str.TemperCoolIntDyn[TERMO_FUNC_SIZE - 1]; |
igor_v | 0:8ad47e2b6f00 | 136 | } |
igor_v | 0:8ad47e2b6f00 | 137 | |
igor_v | 0:8ad47e2b6f00 | 138 | i = 0; |
igor_v | 0:8ad47e2b6f00 | 139 | while( t > Device_blk.Str.TemperCoolIntDyn[i] ) i++; |
igor_v | 0:8ad47e2b6f00 | 140 | |
igor_v | 0:8ad47e2b6f00 | 141 | TermoCompDelta = ( Device_blk.Str.ThermoCoolDelta[i] - dThermoCoolDeltaPer_dTermo[i] * (float)( Device_blk.Str.TemperCoolIntDyn[i] - t ) ); |
igor_v | 0:8ad47e2b6f00 | 142 | } |
igor_v | 0:8ad47e2b6f00 | 143 | return TermoCompDelta; |
igor_v | 0:8ad47e2b6f00 | 144 | |
igor_v | 0:8ad47e2b6f00 | 145 | } // DynamicDeltaCalc |
igor_v | 0:8ad47e2b6f00 | 146 | |
igor_v | 0:8ad47e2b6f00 | 147 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 148 | ** Function name: clc_ThermoSensors |
igor_v | 0:8ad47e2b6f00 | 149 | ** |
igor_v | 0:8ad47e2b6f00 | 150 | ** Descriptions: Procedure of calculating of the normalized temperaturre vector |
igor_v | 0:8ad47e2b6f00 | 151 | ** |
igor_v | 0:8ad47e2b6f00 | 152 | ** parameters: None |
igor_v | 0:8ad47e2b6f00 | 153 | ** Returned value: None |
igor_v | 0:8ad47e2b6f00 | 154 | ** |
igor_v | 0:8ad47e2b6f00 | 155 | ******************************************************************************/ |
igor_v | 0:8ad47e2b6f00 | 156 | void clc_ThermoSensors(void) |
igor_v | 0:8ad47e2b6f00 | 157 | { |
igor_v | 0:8ad47e2b6f00 | 158 | unsigned i; |
igor_v | 0:8ad47e2b6f00 | 159 | static int TS_sum = 0; |
igor_v | 0:8ad47e2b6f00 | 160 | static int seconds_aver = 0, TenSeconds = 0; |
igor_v | 0:8ad47e2b6f00 | 161 | static int Temp_AverPrevDynCalc = -7000; |
igor_v | 0:8ad47e2b6f00 | 162 | static int StartRdy = 1; |
igor_v | 0:8ad47e2b6f00 | 163 | static int PrevTemp = -7000; |
igor_v | 0:8ad47e2b6f00 | 164 | |
igor_v | 0:8ad47e2b6f00 | 165 | for (i=0; i<2; i++) |
igor_v | 0:8ad47e2b6f00 | 166 | { |
igor_v | 1:f2adcae3d304 | 167 | //e. conversion of temperature values on ADC output //r. �������������� �������� ����������� �� ������ ��� |
igor_v | 1:f2adcae3d304 | 168 | //e. to range -32768 .. +32767 ( additional code; format 1.15 ) //r. � ��������� -32768 .. +32767 (��������. ���; ������ 1.15) |
igor_v | 0:8ad47e2b6f00 | 169 | /* Output.Str.Tmp_Out[i] = mac_r(Device_blk.Str.Tmp_bias[i] << 16, |
igor_v | 0:8ad47e2b6f00 | 170 | (Input.StrIn.Tmp_in[i] - 0x8000), |
igor_v | 0:8ad47e2b6f00 | 171 | Device_blk.Str.Tmp_scal[i]);*/ |
igor_v | 0:8ad47e2b6f00 | 172 | Output.Str.Tmp_Out[i+4] = Input.StrIn.Tmp_in[i]; |
igor_v | 0:8ad47e2b6f00 | 173 | } |
igor_v | 0:8ad47e2b6f00 | 174 | |
igor_v | 1:f2adcae3d304 | 175 | if (time_1_Sec == DEVICE_SAMPLE_RATE_uks) //r. ������� 1 ������� |
igor_v | 0:8ad47e2b6f00 | 176 | { |
igor_v | 0:8ad47e2b6f00 | 177 | seconds_aver++; |
igor_v | 0:8ad47e2b6f00 | 178 | } |
igor_v | 0:8ad47e2b6f00 | 179 | |
igor_v | 1:f2adcae3d304 | 180 | if (seconds_aver > TEMP_AVER_PERIOD) //r. ������� TEMP_AVER_PERIOD(4 �������) ������ |
igor_v | 0:8ad47e2b6f00 | 181 | { |
igor_v | 0:8ad47e2b6f00 | 182 | seconds_aver = 0; |
igor_v | 0:8ad47e2b6f00 | 183 | TenSeconds++; |
igor_v | 1:f2adcae3d304 | 184 | PrevTemp = Temp_Aver; //e. save the previous mean temperature for 1 Sec //r. ���������� ���������� ������� ����������� �� ������� |
igor_v | 1:f2adcae3d304 | 185 | Temp_Aver = TS_sum / (DEVICE_SAMPLE_RATE_HZ * TEMP_AVER_PERIOD); //e. calculating mean temperature for 1 Sec //r. ��������� ������� ����������� �� ������� |
igor_v | 0:8ad47e2b6f00 | 186 | |
igor_v | 0:8ad47e2b6f00 | 187 | if (Temp_Aver > PrevTemp) |
igor_v | 0:8ad47e2b6f00 | 188 | { |
igor_v | 0:8ad47e2b6f00 | 189 | TempEvolution++; |
igor_v | 0:8ad47e2b6f00 | 190 | } |
igor_v | 0:8ad47e2b6f00 | 191 | if (Temp_Aver < PrevTemp) |
igor_v | 0:8ad47e2b6f00 | 192 | { |
igor_v | 0:8ad47e2b6f00 | 193 | TempEvolution--; |
igor_v | 0:8ad47e2b6f00 | 194 | } |
igor_v | 0:8ad47e2b6f00 | 195 | |
igor_v | 1:f2adcae3d304 | 196 | TS_sum = 0; //e. reset the sum for calculation of an mean //r. �������� ����� ��� ���������� �������� |
igor_v | 0:8ad47e2b6f00 | 197 | } |
igor_v | 0:8ad47e2b6f00 | 198 | else |
igor_v | 0:8ad47e2b6f00 | 199 | { |
igor_v | 0:8ad47e2b6f00 | 200 | TS_sum += Output.Str.Tmp_Out[TSENS_NUMB]; |
igor_v | 0:8ad47e2b6f00 | 201 | } |
igor_v | 0:8ad47e2b6f00 | 202 | |
igor_v | 0:8ad47e2b6f00 | 203 | if (TenSeconds == 10) // 10 * TEMP_AVER_PERIOD = 40 |
igor_v | 0:8ad47e2b6f00 | 204 | { |
igor_v | 0:8ad47e2b6f00 | 205 | TenSeconds = 0; |
igor_v | 0:8ad47e2b6f00 | 206 | if (TempEvolution > 0) |
igor_v | 0:8ad47e2b6f00 | 207 | { |
igor_v | 0:8ad47e2b6f00 | 208 | IsHeating = 1; |
igor_v | 0:8ad47e2b6f00 | 209 | } |
igor_v | 0:8ad47e2b6f00 | 210 | |
igor_v | 0:8ad47e2b6f00 | 211 | if (TempEvolution < 0) |
igor_v | 0:8ad47e2b6f00 | 212 | { |
igor_v | 0:8ad47e2b6f00 | 213 | IsHeating = 0; |
igor_v | 0:8ad47e2b6f00 | 214 | } |
igor_v | 0:8ad47e2b6f00 | 215 | TempEvolution = 0; |
igor_v | 0:8ad47e2b6f00 | 216 | } |
igor_v | 0:8ad47e2b6f00 | 217 | |
igor_v | 1:f2adcae3d304 | 218 | //e. single calculaiton of some device parameters (measurement on the VALID_START_SEC second after start) //r. ����������� ������ ��������� ���������� ������� (��������� �� VALID_START_SEC ������� ����� ������) |
igor_v | 0:8ad47e2b6f00 | 219 | if (StartRdy) |
igor_v | 0:8ad47e2b6f00 | 220 | { |
igor_v | 0:8ad47e2b6f00 | 221 | if (TenSeconds > VALID_START_4SEC) |
igor_v | 0:8ad47e2b6f00 | 222 | { |
igor_v | 0:8ad47e2b6f00 | 223 | |
igor_v | 1:f2adcae3d304 | 224 | StartRdy = 0; //r. ��������������, ������� ������ ���� �� ������� |
igor_v | 0:8ad47e2b6f00 | 225 | |
igor_v | 0:8ad47e2b6f00 | 226 | if ((Device_blk.Str.TermoMode != TERMO_OFF) && \ |
igor_v | 0:8ad47e2b6f00 | 227 | (Device_blk.Str.TermoMode != TERMO_ON_DYNAMIC_ONLY) && \ |
igor_v | 1:f2adcae3d304 | 228 | (Device_blk.Str.TermoMode != TERMO_ON_DYNAMIC_ONLY_NUMB_OFF)) //r. ����������� ���������������� �������� |
igor_v | 0:8ad47e2b6f00 | 229 | { |
igor_v | 1:f2adcae3d304 | 230 | //r. ������ ����������� ���������������� ����� |
igor_v | 1:f2adcae3d304 | 231 | StartTermoCompens = StaticTermoCompens(Temp_Aver); //r. ��������� ����������� ������� |
igor_v | 0:8ad47e2b6f00 | 232 | } |
igor_v | 0:8ad47e2b6f00 | 233 | DynamicDeltaCalc(); |
igor_v | 0:8ad47e2b6f00 | 234 | |
igor_v | 1:f2adcae3d304 | 235 | //r. ������ ������ ��� ������� ������������, ���������� �� ��������� ����������� |
igor_v | 0:8ad47e2b6f00 | 236 | // DithFreqRangeCalc(); |
igor_v | 0:8ad47e2b6f00 | 237 | |
igor_v | 1:f2adcae3d304 | 238 | //r. ������������ ��� ���������� ������� ����� ��� �� �������������: �������, ��� ������ ������� �������� ���� |
igor_v | 0:8ad47e2b6f00 | 239 | |
igor_v | 0:8ad47e2b6f00 | 240 | |
igor_v | 1:f2adcae3d304 | 241 | //r. ���������� ������ ��� ���������� |
igor_v | 0:8ad47e2b6f00 | 242 | WP_reset_heating = CPL_reset_calc(Device_blk.Str.WP_reset, Device_blk.Str.K_WP_rst_heating, Temp_Aver, Device_blk.Str.TemperNormal); |
igor_v | 1:f2adcae3d304 | 243 | //e. voltage of reset at cooling //r. ���������� ������ ��� ���������� |
igor_v | 0:8ad47e2b6f00 | 244 | WP_reset_cooling = CPL_reset_calc(Device_blk.Str.WP_reset2, Device_blk.Str.K_WP_rst_cooling, Temp_Aver, Device_blk.Str.TemperNormal); |
igor_v | 0:8ad47e2b6f00 | 245 | } |
igor_v | 0:8ad47e2b6f00 | 246 | } |
igor_v | 0:8ad47e2b6f00 | 247 | |
igor_v | 0:8ad47e2b6f00 | 248 | if ( abs(Temp_Aver - Temp_AverPrevDynCalc) > Device_blk.Str.DeltaTempRecalc) |
igor_v | 0:8ad47e2b6f00 | 249 | { |
igor_v | 0:8ad47e2b6f00 | 250 | Temp_AverPrevDynCalc = Temp_Aver; |
igor_v | 0:8ad47e2b6f00 | 251 | DynamicDeltaCalc(); |
igor_v | 1:f2adcae3d304 | 252 | }//r. ������ ������� �� 1 ������� ����������� �������� T4, T5 |
igor_v | 0:8ad47e2b6f00 | 253 | |
igor_v | 0:8ad47e2b6f00 | 254 | // cyclic built-in test |
igor_v | 0:8ad47e2b6f00 | 255 | if ( (Output.Str.Tmp_Out[4] < TS_MIN) || (Output.Str.Tmp_Out[4] > TS_MAX) || (Output.Str.Tmp_Out[5] < TS_MIN) || (Output.Str.Tmp_Out[5] > TS_MAX) ) |
igor_v | 0:8ad47e2b6f00 | 256 | { |
igor_v | 0:8ad47e2b6f00 | 257 | Valid_Data |= THERMO_RANGE_ERROR; |
igor_v | 0:8ad47e2b6f00 | 258 | } |
igor_v | 0:8ad47e2b6f00 | 259 | |
igor_v | 0:8ad47e2b6f00 | 260 | if ( abs( Output.Str.Tmp_Out[4] - Output.Str.Tmp_Out[5]) > TS_DIFF_MAX) |
igor_v | 0:8ad47e2b6f00 | 261 | { |
igor_v | 0:8ad47e2b6f00 | 262 | Valid_Data |= THERMO_DIFF_ERROR; |
igor_v | 0:8ad47e2b6f00 | 263 | } |
igor_v | 0:8ad47e2b6f00 | 264 | } // clc_ThermoSensors |
igor_v | 0:8ad47e2b6f00 | 265 | |
igor_v | 0:8ad47e2b6f00 | 266 | |
igor_v | 0:8ad47e2b6f00 | 267 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 268 | ** Function name: clc_PLC |
igor_v | 0:8ad47e2b6f00 | 269 | ** |
igor_v | 0:8ad47e2b6f00 | 270 | ** Descriptions: Procedure of initial processing for the CPLC regulator |
igor_v | 0:8ad47e2b6f00 | 271 | ** |
igor_v | 0:8ad47e2b6f00 | 272 | ** parameters: None |
igor_v | 0:8ad47e2b6f00 | 273 | ** Returned value: None |
igor_v | 0:8ad47e2b6f00 | 274 | ** |
igor_v | 0:8ad47e2b6f00 | 275 | ******************************************************************************/ |
igor_v | 1:f2adcae3d304 | 276 | void DithFreqRangeCalc(void) //r. ������ ������ ������������ ������� ��� ������� ������������, ��������� �� ������� ����������� |
igor_v | 0:8ad47e2b6f00 | 277 | { |
igor_v | 0:8ad47e2b6f00 | 278 | |
igor_v | 0:8ad47e2b6f00 | 279 | unsigned int min_level, max_level; |
igor_v | 0:8ad47e2b6f00 | 280 | int delta_VB_N; |
igor_v | 0:8ad47e2b6f00 | 281 | |
igor_v | 0:8ad47e2b6f00 | 282 | delta_VB_N = mult_r(Device_blk.Str.K_vb_tu >> DITH_VBN_SHIFT, (Temp_Aver - Device_blk.Str.TemperNormal)); //r.200; |
igor_v | 1:f2adcae3d304 | 283 | //r. !!! ������� ������������ � ����������, � ����� ����� |
igor_v | 0:8ad47e2b6f00 | 284 | min_level = VB_Nmin0 + delta_VB_N; |
igor_v | 0:8ad47e2b6f00 | 285 | max_level = VB_Nmax0 + delta_VB_N; |
igor_v | 0:8ad47e2b6f00 | 286 | // maximum saturation for unsigned levels |
igor_v | 0:8ad47e2b6f00 | 287 | Max_Saturation(&min_level, ((unsigned int)0xFFFF >> DITH_VBN_SHIFT)-1); // min should be always less then max_level by 1 |
igor_v | 0:8ad47e2b6f00 | 288 | Max_Saturation(&max_level, ((unsigned int)0xFFFF >> DITH_VBN_SHIFT)); |
igor_v | 0:8ad47e2b6f00 | 289 | Device_blk.Str.VB_Nmin = min_level << DITH_VBN_SHIFT; |
igor_v | 0:8ad47e2b6f00 | 290 | Device_blk.Str.VB_Nmax = max_level << DITH_VBN_SHIFT; |
igor_v | 0:8ad47e2b6f00 | 291 | |
igor_v | 0:8ad47e2b6f00 | 292 | } // DithFreqRange_calc |
igor_v | 0:8ad47e2b6f00 | 293 |