![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
ThermoCalc.c@232:130a2b5003e6, 2018-01-31 (annotated)
- Committer:
- Kovalev_D
- Date:
- Wed Jan 31 13:41:23 2018 +0000
- Revision:
- 232:130a2b5003e6
- Parent:
- 231:079835d508ef
static termocorr
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 | 21:bc8c1cec3da6 | 5 | int TermoCompens_Sum = 0; |
igor_v | 0:8ad47e2b6f00 | 6 | unsigned int IsHeating; |
igor_v | 21:bc8c1cec3da6 | 7 | //int Tmp_Out[NUM_OF_THERMOSENS]; |
Kovalev_D | 231:079835d508ef | 8 | //int dThermoHeatDeltaPer_dTermo[TERMO_FUNC_SIZE]; |
Kovalev_D | 231:079835d508ef | 9 | //int dThermoCoolDeltaPer_dTermo[TERMO_FUNC_SIZE]; |
Kovalev_D | 231:079835d508ef | 10 | //int dFuncPer_dTermo[TERMO_FUNC_SIZE]; |
igor_v | 21:bc8c1cec3da6 | 11 | int TermoCompDelta; |
igor_v | 21:bc8c1cec3da6 | 12 | int Temp_Aver; //e. the mean temperature for 1 Sec for T4 sensor //r. средняя температура за 1 секунду для датчика T4 |
igor_v | 21:bc8c1cec3da6 | 13 | int TempEvolution = 0; |
igor_v | 21:bc8c1cec3da6 | 14 | int StartTermoCompens = 0; //e. initial thermocompensation (in XXX seconds after start ) //r. начальная термокомпенсация (через ХХХ секунд после старта) |
igor_v | 0:8ad47e2b6f00 | 15 | |
igor_v | 21:bc8c1cec3da6 | 16 | extern int WP_reset_heating; //e. voltage of reset at heating //r. напряжение сброса при нагревании |
igor_v | 21:bc8c1cec3da6 | 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 | 21:bc8c1cec3da6 | 21 | if (*lvl>limit) *lvl = limit; |
igor_v | 0:8ad47e2b6f00 | 22 | } |
igor_v | 0:8ad47e2b6f00 | 23 | |
igor_v | 0:8ad47e2b6f00 | 24 | /*{ |
igor_v | 21:bc8c1cec3da6 | 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 | 21:bc8c1cec3da6 | 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 | 21:bc8c1cec3da6 | 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 | 21:bc8c1cec3da6 | 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 | 21:bc8c1cec3da6 | 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 | 21:bc8c1cec3da6 | 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 | 21:bc8c1cec3da6 | 47 | |
igor_v | 0:8ad47e2b6f00 | 48 | case TERMO_OFF: |
igor_v | 0:8ad47e2b6f00 | 49 | default: |
igor_v | 21:bc8c1cec3da6 | 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 | 21:bc8c1cec3da6 | 57 | ** Descriptions: Procedure of |
igor_v | 0:8ad47e2b6f00 | 58 | ** |
igor_v | 21:bc8c1cec3da6 | 59 | ** parameters: None |
igor_v | 21:bc8c1cec3da6 | 60 | ** Returned value: None |
igor_v | 21:bc8c1cec3da6 | 61 | ** |
igor_v | 0:8ad47e2b6f00 | 62 | ******************************************************************************/ |
igor_v | 21:bc8c1cec3da6 | 63 | int StaticTermoCompens(int temperature) //r. расчет статической составляющей термокомпенсации за один период прибора (100 мкс) |
igor_v | 0:8ad47e2b6f00 | 64 | { |
Kovalev_D | 129:406995a91322 | 65 | /* |
igor_v | 21:bc8c1cec3da6 | 66 | float TermoCompens_Curr; //r. величина термокомпенсации за один период прибора (100 мкс) |
igor_v | 21:bc8c1cec3da6 | 67 | |
igor_v | 21:bc8c1cec3da6 | 68 | int i, t; |
igor_v | 0:8ad47e2b6f00 | 69 | |
igor_v | 21:bc8c1cec3da6 | 70 | //r. используем только термодатчик TSENS_NUMB |
igor_v | 21:bc8c1cec3da6 | 71 | //r. для новых термодатчиков: T4, для старых: T1 |
igor_v | 21:bc8c1cec3da6 | 72 | //r. и используем кусочно-непрерывную термокомпенсацию |
igor_v | 21:bc8c1cec3da6 | 73 | |
igor_v | 21:bc8c1cec3da6 | 74 | //r. Tmp_Out[TSENS_NUMB] = 8960; //-2560; //5120; //8000; // -2600; //-5000; |
igor_v | 21:bc8c1cec3da6 | 75 | |
igor_v | 21:bc8c1cec3da6 | 76 | t = temperature; |
igor_v | 21:bc8c1cec3da6 | 77 | if(t > Device_blk.Str.TemperInt[TERMO_FUNC_SIZE - 1]) { |
igor_v | 21:bc8c1cec3da6 | 78 | t = Device_blk.Str.TemperInt[TERMO_FUNC_SIZE - 1]; |
igor_v | 21:bc8c1cec3da6 | 79 | } |
igor_v | 0:8ad47e2b6f00 | 80 | |
igor_v | 21:bc8c1cec3da6 | 81 | i = 0; |
igor_v | 21:bc8c1cec3da6 | 82 | while( t > Device_blk.Str.TemperInt[i] ) i++; |
igor_v | 0:8ad47e2b6f00 | 83 | |
igor_v | 21:bc8c1cec3da6 | 84 | //r. Tmp_Out[5] = i; |
igor_v | 21:bc8c1cec3da6 | 85 | TermoCompens_Curr = Device_blk.Str.TermoFunc[i] - dFuncPer_dTermo[i] * (float)( Device_blk.Str.TemperInt[i] - t ); |
igor_v | 0:8ad47e2b6f00 | 86 | |
igor_v | 21:bc8c1cec3da6 | 87 | //r. Отладка |
igor_v | 21:bc8c1cec3da6 | 88 | //r. TermoCompens_Curr = 1.111111125; // отладка |
igor_v | 21:bc8c1cec3da6 | 89 | //r.TermoCompens_Curr = // 0.25; // за 1 сек накапливается 2500 импульсов |
Kovalev_D | 129:406995a91322 | 90 | |
igor_v | 0:8ad47e2b6f00 | 91 | |
igor_v | 21:bc8c1cec3da6 | 92 | // TermoCompens_Curr = LONG_2_FRACT_14_18(TermoCompens_Curr); //r. TermoCompens_Curr переводим в формат 14.18 |
igor_v | 0:8ad47e2b6f00 | 93 | |
Kovalev_D | 129:406995a91322 | 94 | return TermoCompens_Curr;*/ |
igor_v | 0:8ad47e2b6f00 | 95 | } // StaticTermoCompens |
igor_v | 0:8ad47e2b6f00 | 96 | |
igor_v | 0:8ad47e2b6f00 | 97 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 98 | ** Function name: DynamicDeltaCalc |
igor_v | 0:8ad47e2b6f00 | 99 | ** |
igor_v | 21:bc8c1cec3da6 | 100 | ** Descriptions: Procedure of |
igor_v | 0:8ad47e2b6f00 | 101 | ** |
igor_v | 21:bc8c1cec3da6 | 102 | ** parameters: None |
igor_v | 21:bc8c1cec3da6 | 103 | ** Returned value: Thermocompensation addition |
igor_v | 21:bc8c1cec3da6 | 104 | ** |
igor_v | 0:8ad47e2b6f00 | 105 | ******************************************************************************/ |
igor_v | 21:bc8c1cec3da6 | 106 | int DynamicDeltaCalc() //e. calculation the addition termocompensation for 1 reset //r. расчет добавки термокомпенсации на одно обнуление |
igor_v | 0:8ad47e2b6f00 | 107 | { |
Kovalev_D | 129:406995a91322 | 108 | /* |
igor_v | 21:bc8c1cec3da6 | 109 | int i, t; |
igor_v | 21:bc8c1cec3da6 | 110 | |
igor_v | 21:bc8c1cec3da6 | 111 | t = Temp_Aver; |
igor_v | 0:8ad47e2b6f00 | 112 | |
igor_v | 21:bc8c1cec3da6 | 113 | if (IsHeating) { |
igor_v | 21:bc8c1cec3da6 | 114 | if(t > Device_blk.Str.TemperIntDyn[TERMO_FUNC_SIZE - 1]) { |
igor_v | 21:bc8c1cec3da6 | 115 | t = Device_blk.Str.TemperIntDyn[TERMO_FUNC_SIZE - 1]; |
igor_v | 21:bc8c1cec3da6 | 116 | } |
igor_v | 21:bc8c1cec3da6 | 117 | |
igor_v | 21:bc8c1cec3da6 | 118 | i = 0; |
igor_v | 21:bc8c1cec3da6 | 119 | while( t > Device_blk.Str.TemperIntDyn[i] ) i++; |
igor_v | 0:8ad47e2b6f00 | 120 | |
igor_v | 21:bc8c1cec3da6 | 121 | TermoCompDelta = ( Device_blk.Str.ThermoHeatDelta[i] - dThermoHeatDeltaPer_dTermo[i] * (float)( Device_blk.Str.TemperIntDyn[i] - t ) ); |
igor_v | 21:bc8c1cec3da6 | 122 | } else { |
igor_v | 21:bc8c1cec3da6 | 123 | if(t > Device_blk.Str.TemperCoolIntDyn[TERMO_FUNC_SIZE - 1]) { |
igor_v | 21:bc8c1cec3da6 | 124 | t = Device_blk.Str.TemperCoolIntDyn[TERMO_FUNC_SIZE - 1]; |
igor_v | 21:bc8c1cec3da6 | 125 | } |
igor_v | 21:bc8c1cec3da6 | 126 | |
igor_v | 21:bc8c1cec3da6 | 127 | i = 0; |
igor_v | 21:bc8c1cec3da6 | 128 | while( t > Device_blk.Str.TemperCoolIntDyn[i] ) i++; |
igor_v | 21:bc8c1cec3da6 | 129 | |
igor_v | 21:bc8c1cec3da6 | 130 | TermoCompDelta = ( Device_blk.Str.ThermoCoolDelta[i] - dThermoCoolDeltaPer_dTermo[i] * (float)( Device_blk.Str.TemperCoolIntDyn[i] - t ) ); |
igor_v | 0:8ad47e2b6f00 | 131 | } |
igor_v | 21:bc8c1cec3da6 | 132 | return TermoCompDelta; |
Kovalev_D | 129:406995a91322 | 133 | */ |
igor_v | 0:8ad47e2b6f00 | 134 | } // DynamicDeltaCalc |
igor_v | 0:8ad47e2b6f00 | 135 | |
igor_v | 0:8ad47e2b6f00 | 136 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 137 | ** Function name: clc_ThermoSensors |
igor_v | 0:8ad47e2b6f00 | 138 | ** |
igor_v | 21:bc8c1cec3da6 | 139 | ** Descriptions: Procedure of calculating of the normalized temperaturre vector |
igor_v | 0:8ad47e2b6f00 | 140 | ** |
igor_v | 21:bc8c1cec3da6 | 141 | ** parameters: None |
igor_v | 21:bc8c1cec3da6 | 142 | ** Returned value: None |
igor_v | 21:bc8c1cec3da6 | 143 | ** |
igor_v | 0:8ad47e2b6f00 | 144 | ******************************************************************************/ |
igor_v | 21:bc8c1cec3da6 | 145 | void clc_ThermoSensors(void) |
Kovalev_D | 129:406995a91322 | 146 | {/* |
igor_v | 21:bc8c1cec3da6 | 147 | unsigned i; |
igor_v | 21:bc8c1cec3da6 | 148 | static int TS_sum = 0; |
igor_v | 21:bc8c1cec3da6 | 149 | static int seconds_aver = 0, TenSeconds = 0; |
igor_v | 21:bc8c1cec3da6 | 150 | static int Temp_AverPrevDynCalc = -7000; |
igor_v | 21:bc8c1cec3da6 | 151 | static int StartRdy = 1; |
igor_v | 21:bc8c1cec3da6 | 152 | static int PrevTemp = -7000; |
igor_v | 0:8ad47e2b6f00 | 153 | |
igor_v | 21:bc8c1cec3da6 | 154 | for (i=0; i<2; i++) { |
igor_v | 21:bc8c1cec3da6 | 155 | //e. conversion of temperature values on ADC output //r. преобразование значений температуры на выходе АЦП |
igor_v | 21:bc8c1cec3da6 | 156 | //e. to range -32768 .. +32767 ( additional code; format 1.15 ) //r. к диапазону -32768 .. +32767 (дополнит. код; формат 1.15) |
Kovalev_D | 129:406995a91322 | 157 | |
igor_v | 21:bc8c1cec3da6 | 158 | Output.Str.Tmp_Out[i+4] = Input.StrIn.Tmp_in[i]; |
igor_v | 21:bc8c1cec3da6 | 159 | } |
igor_v | 0:8ad47e2b6f00 | 160 | |
igor_v | 21:bc8c1cec3da6 | 161 | if (time_1_Sec == DEVICE_SAMPLE_RATE_uks) { //r. истекла 1 секунда |
igor_v | 21:bc8c1cec3da6 | 162 | seconds_aver++; |
igor_v | 21:bc8c1cec3da6 | 163 | } |
igor_v | 0:8ad47e2b6f00 | 164 | |
igor_v | 21:bc8c1cec3da6 | 165 | if (seconds_aver > TEMP_AVER_PERIOD) { //r. истекли TEMP_AVER_PERIOD(4 секунды) секунд |
igor_v | 21:bc8c1cec3da6 | 166 | seconds_aver = 0; |
igor_v | 21:bc8c1cec3da6 | 167 | TenSeconds++; |
igor_v | 21:bc8c1cec3da6 | 168 | PrevTemp = Temp_Aver; //e. save the previous mean temperature for 1 Sec //r. запоминаем предыдущую среднюю температуру за секунду |
igor_v | 21:bc8c1cec3da6 | 169 | Temp_Aver = TS_sum / (DEVICE_SAMPLE_RATE_HZ * TEMP_AVER_PERIOD); //e. calculating mean temperature for 1 Sec //r. вычисляем среднюю температуру за секунду |
igor_v | 0:8ad47e2b6f00 | 170 | |
igor_v | 21:bc8c1cec3da6 | 171 | if (Temp_Aver > PrevTemp) { |
igor_v | 21:bc8c1cec3da6 | 172 | TempEvolution++; |
igor_v | 21:bc8c1cec3da6 | 173 | } |
igor_v | 21:bc8c1cec3da6 | 174 | if (Temp_Aver < PrevTemp) { |
igor_v | 21:bc8c1cec3da6 | 175 | TempEvolution--; |
igor_v | 21:bc8c1cec3da6 | 176 | } |
igor_v | 21:bc8c1cec3da6 | 177 | |
igor_v | 21:bc8c1cec3da6 | 178 | TS_sum = 0; //e. reset the sum for calculation of an mean //r. обнуляем сумму для вычисления среднего |
igor_v | 21:bc8c1cec3da6 | 179 | } else { |
igor_v | 21:bc8c1cec3da6 | 180 | TS_sum += Output.Str.Tmp_Out[TSENS_NUMB]; |
igor_v | 21:bc8c1cec3da6 | 181 | } |
igor_v | 0:8ad47e2b6f00 | 182 | |
igor_v | 21:bc8c1cec3da6 | 183 | if (TenSeconds == 10) { // 10 * TEMP_AVER_PERIOD = 40 |
igor_v | 21:bc8c1cec3da6 | 184 | TenSeconds = 0; |
igor_v | 21:bc8c1cec3da6 | 185 | if (TempEvolution > 0) { |
igor_v | 21:bc8c1cec3da6 | 186 | IsHeating = 1; |
igor_v | 21:bc8c1cec3da6 | 187 | } |
igor_v | 21:bc8c1cec3da6 | 188 | |
igor_v | 21:bc8c1cec3da6 | 189 | if (TempEvolution < 0) { |
igor_v | 21:bc8c1cec3da6 | 190 | IsHeating = 0; |
igor_v | 21:bc8c1cec3da6 | 191 | } |
igor_v | 21:bc8c1cec3da6 | 192 | TempEvolution = 0; |
igor_v | 21:bc8c1cec3da6 | 193 | } |
igor_v | 0:8ad47e2b6f00 | 194 | |
igor_v | 21:bc8c1cec3da6 | 195 | //e. single calculaiton of some device parameters (measurement on the VALID_START_SEC second after start) //r. однократный расчет некоторых параметров прибора (измерение на VALID_START_SEC секунде после старта) |
igor_v | 21:bc8c1cec3da6 | 196 | if (StartRdy) { |
igor_v | 21:bc8c1cec3da6 | 197 | if (TenSeconds > VALID_START_4SEC) { |
igor_v | 21:bc8c1cec3da6 | 198 | |
igor_v | 21:bc8c1cec3da6 | 199 | StartRdy = 0; //r. самоблокировка, поэтому больше сюда не заходим |
igor_v | 21:bc8c1cec3da6 | 200 | |
igor_v | 21:bc8c1cec3da6 | 201 | if ((Device_blk.Str.TermoMode != TERMO_OFF) && \ |
igor_v | 21:bc8c1cec3da6 | 202 | (Device_blk.Str.TermoMode != TERMO_ON_DYNAMIC_ONLY) && \ |
igor_v | 21:bc8c1cec3da6 | 203 | (Device_blk.Str.TermoMode != TERMO_ON_DYNAMIC_ONLY_NUMB_OFF)) { //r. статическая термокомпенсация включена |
igor_v | 21:bc8c1cec3da6 | 204 | //r. расчет статической термокомпенсации числа |
igor_v | 21:bc8c1cec3da6 | 205 | StartTermoCompens = StaticTermoCompens(Temp_Aver); //r. стартовая температуры прибора |
igor_v | 21:bc8c1cec3da6 | 206 | } |
igor_v | 21:bc8c1cec3da6 | 207 | DynamicDeltaCalc(); |
igor_v | 0:8ad47e2b6f00 | 208 | |
igor_v | 21:bc8c1cec3da6 | 209 | //r. расчет границ для частоты вибропривода, зависящего от стартовой температуры |
igor_v | 21:bc8c1cec3da6 | 210 | // DithFreqRangeCalc(); |
igor_v | 21:bc8c1cec3da6 | 211 | |
igor_v | 21:bc8c1cec3da6 | 212 | //r. коэффициенты для полосового фильтра квази ДУП не пересчитываем: считаем, что полоса фильтра заведомо шире |
igor_v | 21:bc8c1cec3da6 | 213 | |
igor_v | 0:8ad47e2b6f00 | 214 | |
igor_v | 21:bc8c1cec3da6 | 215 | //r. напряжение сброса при нагревании |
igor_v | 21:bc8c1cec3da6 | 216 | 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 | 21:bc8c1cec3da6 | 217 | //e. voltage of reset at cooling //r. напряжение сброса при охлаждении |
igor_v | 21:bc8c1cec3da6 | 218 | 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 | 21:bc8c1cec3da6 | 219 | } |
igor_v | 21:bc8c1cec3da6 | 220 | } |
igor_v | 0:8ad47e2b6f00 | 221 | |
igor_v | 21:bc8c1cec3da6 | 222 | if ( abs(Temp_Aver - Temp_AverPrevDynCalc) > Device_blk.Str.DeltaTempRecalc) { |
igor_v | 21:bc8c1cec3da6 | 223 | Temp_AverPrevDynCalc = Temp_Aver; |
igor_v | 21:bc8c1cec3da6 | 224 | DynamicDeltaCalc(); |
igor_v | 21:bc8c1cec3da6 | 225 | }//r. расчет средней за 1 секунду температуры датчиков T4, T5 |
igor_v | 0:8ad47e2b6f00 | 226 | |
igor_v | 21:bc8c1cec3da6 | 227 | // cyclic built-in test |
igor_v | 21:bc8c1cec3da6 | 228 | 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 | 21:bc8c1cec3da6 | 229 | Valid_Data |= THERMO_RANGE_ERROR; |
igor_v | 21:bc8c1cec3da6 | 230 | } |
igor_v | 0:8ad47e2b6f00 | 231 | |
igor_v | 21:bc8c1cec3da6 | 232 | if ( abs( Output.Str.Tmp_Out[4] - Output.Str.Tmp_Out[5]) > TS_DIFF_MAX) { |
igor_v | 21:bc8c1cec3da6 | 233 | Valid_Data |= THERMO_DIFF_ERROR; |
Kovalev_D | 129:406995a91322 | 234 | }*/ |
igor_v | 0:8ad47e2b6f00 | 235 | } // clc_ThermoSensors |
igor_v | 0:8ad47e2b6f00 | 236 | |
igor_v | 0:8ad47e2b6f00 | 237 | |
igor_v | 0:8ad47e2b6f00 | 238 | /****************************************************************************** |
igor_v | 0:8ad47e2b6f00 | 239 | ** Function name: clc_PLC |
igor_v | 0:8ad47e2b6f00 | 240 | ** |
igor_v | 21:bc8c1cec3da6 | 241 | ** Descriptions: Procedure of initial processing for the CPLC regulator |
igor_v | 0:8ad47e2b6f00 | 242 | ** |
igor_v | 21:bc8c1cec3da6 | 243 | ** parameters: None |
igor_v | 21:bc8c1cec3da6 | 244 | ** Returned value: None |
igor_v | 21:bc8c1cec3da6 | 245 | ** |
igor_v | 0:8ad47e2b6f00 | 246 | ******************************************************************************/ |
igor_v | 21:bc8c1cec3da6 | 247 | void DithFreqRangeCalc(void) //r. расчет границ коэффициента деления для частоты вибропривода, зависящих от текущей температуры |
Kovalev_D | 129:406995a91322 | 248 | {/* |
igor_v | 0:8ad47e2b6f00 | 249 | |
igor_v | 21:bc8c1cec3da6 | 250 | unsigned int min_level, max_level; |
igor_v | 21:bc8c1cec3da6 | 251 | int delta_VB_N; |
igor_v | 21:bc8c1cec3da6 | 252 | |
igor_v | 21:bc8c1cec3da6 | 253 | delta_VB_N = mult_r(Device_blk.Str.K_vb_tu >> DITH_VBN_SHIFT, (Temp_Aver - Device_blk.Str.TemperNormal)); //r.200; |
igor_v | 21:bc8c1cec3da6 | 254 | //r. !!! сделать суммирование с насыщением, а затем сдвиг |
igor_v | 21:bc8c1cec3da6 | 255 | min_level = VB_Nmin0 + delta_VB_N; |
igor_v | 21:bc8c1cec3da6 | 256 | max_level = VB_Nmax0 + delta_VB_N; |
igor_v | 21:bc8c1cec3da6 | 257 | // maximum saturation for unsigned levels |
igor_v | 21:bc8c1cec3da6 | 258 | Max_Saturation(&min_level, ((unsigned int)0xFFFF >> DITH_VBN_SHIFT)-1); // min should be always less then max_level by 1 |
igor_v | 21:bc8c1cec3da6 | 259 | Max_Saturation(&max_level, ((unsigned int)0xFFFF >> DITH_VBN_SHIFT)); |
igor_v | 21:bc8c1cec3da6 | 260 | Device_blk.Str.VB_Nmin = min_level << DITH_VBN_SHIFT; |
igor_v | 21:bc8c1cec3da6 | 261 | Device_blk.Str.VB_Nmax = max_level << DITH_VBN_SHIFT; |
Kovalev_D | 129:406995a91322 | 262 | */ |
igor_v | 0:8ad47e2b6f00 | 263 | } // DithFreqRange_calc |
igor_v | 0:8ad47e2b6f00 | 264 | |
igor_v | 21:bc8c1cec3da6 | 265 |