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