dd
Dependencies: BufferedSerial FastAnalogIn FastPWM mbed SHT75
controlt.cpp@10:c751a0e8b7f9, 2016-07-11 (annotated)
- Committer:
- sbh9428
- Date:
- Mon Jul 11 01:05:52 2016 +0000
- Revision:
- 10:c751a0e8b7f9
- Parent:
- 9:6ef12ac2ddc3
fff;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sbh9428 | 0:9bfc4aea91e2 | 1 | /* |
sbh9428 | 0:9bfc4aea91e2 | 2 | * controlt.cpp |
sbh9428 | 0:9bfc4aea91e2 | 3 | * |
sbh9428 | 0:9bfc4aea91e2 | 4 | * Created on: 2016. 2. 19. |
sbh9428 | 0:9bfc4aea91e2 | 5 | * Author: sbh9428 |
sbh9428 | 0:9bfc4aea91e2 | 6 | */ |
sbh9428 | 0:9bfc4aea91e2 | 7 | |
sbh9428 | 0:9bfc4aea91e2 | 8 | #include "controlt.h" |
sbh9428 | 0:9bfc4aea91e2 | 9 | |
sbh9428 | 0:9bfc4aea91e2 | 10 | control_t::control_t() { |
sbh9428 | 0:9bfc4aea91e2 | 11 | // TODO Auto-generated constructor stub |
sbh9428 | 0:9bfc4aea91e2 | 12 | |
sbh9428 | 0:9bfc4aea91e2 | 13 | } |
sbh9428 | 0:9bfc4aea91e2 | 14 | |
sbh9428 | 2:4c51394fb35b | 15 | control_t::control_t(temp_sensor_t* _temp_sensor, peltier_t* _peltier,BufferedSerial *_pc) |
sbh9428 | 0:9bfc4aea91e2 | 16 | { |
sbh9428 | 1:5c42ec7f1aeb | 17 | log_count=0; |
sbh9428 | 6:c2fb5c188e8a | 18 | time=0; |
sbh9428 | 1:5c42ec7f1aeb | 19 | |
sbh9428 | 1:5c42ec7f1aeb | 20 | target_temp=15; |
sbh9428 | 1:5c42ec7f1aeb | 21 | P_value=0; |
sbh9428 | 1:5c42ec7f1aeb | 22 | I_value=0; |
sbh9428 | 1:5c42ec7f1aeb | 23 | D_value=0; |
sbh9428 | 1:5c42ec7f1aeb | 24 | |
sbh9428 | 0:9bfc4aea91e2 | 25 | temp_sensor=_temp_sensor; |
sbh9428 | 0:9bfc4aea91e2 | 26 | peltier=_peltier; |
sbh9428 | 2:4c51394fb35b | 27 | pc=_pc; |
sbh9428 | 2:4c51394fb35b | 28 | |
sbh9428 | 2:4c51394fb35b | 29 | table_count=0; |
sbh9428 | 2:4c51394fb35b | 30 | table_mode=0; |
sbh9428 | 10:c751a0e8b7f9 | 31 | |
sbh9428 | 10:c751a0e8b7f9 | 32 | repeatTime=0; |
sbh9428 | 10:c751a0e8b7f9 | 33 | repeatCount=0; |
sbh9428 | 10:c751a0e8b7f9 | 34 | repeatSide=0; |
sbh9428 | 0:9bfc4aea91e2 | 35 | } |
sbh9428 | 0:9bfc4aea91e2 | 36 | |
sbh9428 | 0:9bfc4aea91e2 | 37 | control_t::~control_t() { |
sbh9428 | 0:9bfc4aea91e2 | 38 | // TODO Auto-generated destructor stub |
sbh9428 | 0:9bfc4aea91e2 | 39 | } |
sbh9428 | 0:9bfc4aea91e2 | 40 | |
sbh9428 | 0:9bfc4aea91e2 | 41 | float control_t::get_temp() |
sbh9428 | 0:9bfc4aea91e2 | 42 | { |
sbh9428 | 0:9bfc4aea91e2 | 43 | return temp_sensor->get_temp(); |
sbh9428 | 0:9bfc4aea91e2 | 44 | } |
sbh9428 | 0:9bfc4aea91e2 | 45 | |
sbh9428 | 0:9bfc4aea91e2 | 46 | void control_t::control_PWM(float PWM) |
sbh9428 | 0:9bfc4aea91e2 | 47 | { |
sbh9428 | 0:9bfc4aea91e2 | 48 | peltier->set_PWM(PWM); |
sbh9428 | 0:9bfc4aea91e2 | 49 | } |
sbh9428 | 0:9bfc4aea91e2 | 50 | |
sbh9428 | 0:9bfc4aea91e2 | 51 | void control_t::control_temp() |
sbh9428 | 0:9bfc4aea91e2 | 52 | { |
sbh9428 | 1:5c42ec7f1aeb | 53 | PWM_value+=calc_P(); |
sbh9428 | 0:9bfc4aea91e2 | 54 | |
sbh9428 | 1:5c42ec7f1aeb | 55 | PWM_value+=calc_I(); |
sbh9428 | 0:9bfc4aea91e2 | 56 | |
sbh9428 | 1:5c42ec7f1aeb | 57 | PWM_value+=calc_D(); |
sbh9428 | 1:5c42ec7f1aeb | 58 | |
sbh9428 | 1:5c42ec7f1aeb | 59 | if(PWM_value>1) |
sbh9428 | 1:5c42ec7f1aeb | 60 | { |
sbh9428 | 1:5c42ec7f1aeb | 61 | PWM_value=1; |
sbh9428 | 1:5c42ec7f1aeb | 62 | } |
sbh9428 | 1:5c42ec7f1aeb | 63 | if(PWM_value<-1) |
sbh9428 | 1:5c42ec7f1aeb | 64 | { |
sbh9428 | 1:5c42ec7f1aeb | 65 | PWM_value=-1; |
sbh9428 | 1:5c42ec7f1aeb | 66 | } |
sbh9428 | 1:5c42ec7f1aeb | 67 | peltier->set_PWM(PWM_value); |
sbh9428 | 0:9bfc4aea91e2 | 68 | } |
sbh9428 | 0:9bfc4aea91e2 | 69 | |
sbh9428 | 0:9bfc4aea91e2 | 70 | void control_t::set_mode(int _mode) |
sbh9428 | 0:9bfc4aea91e2 | 71 | { |
sbh9428 | 0:9bfc4aea91e2 | 72 | mode=_mode; |
sbh9428 | 4:7ca449fca19b | 73 | if(mode==4) |
sbh9428 | 6:c2fb5c188e8a | 74 | { |
sbh9428 | 6:c2fb5c188e8a | 75 | start_temp=temp_sensor->get_temp(); |
sbh9428 | 6:c2fb5c188e8a | 76 | time=0; |
sbh9428 | 6:c2fb5c188e8a | 77 | } |
sbh9428 | 1:5c42ec7f1aeb | 78 | } |
sbh9428 | 1:5c42ec7f1aeb | 79 | |
sbh9428 | 1:5c42ec7f1aeb | 80 | void control_t::set_PWM_value(float _PWM_value) |
sbh9428 | 1:5c42ec7f1aeb | 81 | { |
sbh9428 | 1:5c42ec7f1aeb | 82 | PWM_value=_PWM_value; |
sbh9428 | 1:5c42ec7f1aeb | 83 | } |
sbh9428 | 1:5c42ec7f1aeb | 84 | |
sbh9428 | 1:5c42ec7f1aeb | 85 | void control_t::set_target_temp(float _target_temp) |
sbh9428 | 1:5c42ec7f1aeb | 86 | { |
sbh9428 | 1:5c42ec7f1aeb | 87 | target_temp=_target_temp; |
sbh9428 | 1:5c42ec7f1aeb | 88 | } |
sbh9428 | 1:5c42ec7f1aeb | 89 | |
sbh9428 | 1:5c42ec7f1aeb | 90 | void control_t::set_P_value(float _P_value) |
sbh9428 | 1:5c42ec7f1aeb | 91 | { |
sbh9428 | 1:5c42ec7f1aeb | 92 | P_value=_P_value; |
sbh9428 | 1:5c42ec7f1aeb | 93 | } |
sbh9428 | 1:5c42ec7f1aeb | 94 | |
sbh9428 | 1:5c42ec7f1aeb | 95 | void control_t::set_I_value(float _I_value) |
sbh9428 | 1:5c42ec7f1aeb | 96 | { |
sbh9428 | 1:5c42ec7f1aeb | 97 | I_value=_I_value; |
sbh9428 | 1:5c42ec7f1aeb | 98 | } |
sbh9428 | 1:5c42ec7f1aeb | 99 | |
sbh9428 | 1:5c42ec7f1aeb | 100 | void control_t::set_D_value(float _D_value) |
sbh9428 | 1:5c42ec7f1aeb | 101 | { |
sbh9428 | 1:5c42ec7f1aeb | 102 | D_value=_D_value; |
sbh9428 | 1:5c42ec7f1aeb | 103 | } |
sbh9428 | 1:5c42ec7f1aeb | 104 | |
sbh9428 | 3:72644690e2e6 | 105 | void control_t::set_period(int _period) |
sbh9428 | 3:72644690e2e6 | 106 | { |
sbh9428 | 3:72644690e2e6 | 107 | period=_period; |
sbh9428 | 3:72644690e2e6 | 108 | } |
sbh9428 | 3:72644690e2e6 | 109 | |
sbh9428 | 4:7ca449fca19b | 110 | void control_t::set_start_temp(float _start_temp) |
sbh9428 | 4:7ca449fca19b | 111 | { |
sbh9428 | 4:7ca449fca19b | 112 | start_temp=_start_temp; |
sbh9428 | 4:7ca449fca19b | 113 | } |
sbh9428 | 4:7ca449fca19b | 114 | |
sbh9428 | 1:5c42ec7f1aeb | 115 | void control_t::refresh_PWM() |
sbh9428 | 1:5c42ec7f1aeb | 116 | { |
sbh9428 | 1:5c42ec7f1aeb | 117 | write_log(); |
sbh9428 | 10:c751a0e8b7f9 | 118 | time+=10; |
sbh9428 | 10:c751a0e8b7f9 | 119 | printf("\n%1.4f, %d, %d, %d, %d, %d, %d, %d, %2.2f, %2.2f, %2.2f, %2.2f", P_value, time, mode, repeatTime, repeatCount, repeatSide, highTempTime, lowTempTime, highTemp, lowTemp, target_temp, temp_sensor->get_temp()); |
sbh9428 | 1:5c42ec7f1aeb | 120 | if(mode==0) |
sbh9428 | 1:5c42ec7f1aeb | 121 | { |
sbh9428 | 1:5c42ec7f1aeb | 122 | PWM_value=0; |
sbh9428 | 1:5c42ec7f1aeb | 123 | control_PWM(0); |
sbh9428 | 1:5c42ec7f1aeb | 124 | } |
sbh9428 | 1:5c42ec7f1aeb | 125 | else if(mode==1) |
sbh9428 | 1:5c42ec7f1aeb | 126 | { |
sbh9428 | 1:5c42ec7f1aeb | 127 | } |
sbh9428 | 1:5c42ec7f1aeb | 128 | else if(mode==2) |
sbh9428 | 1:5c42ec7f1aeb | 129 | { |
sbh9428 | 1:5c42ec7f1aeb | 130 | control_temp(); |
sbh9428 | 1:5c42ec7f1aeb | 131 | } |
sbh9428 | 2:4c51394fb35b | 132 | else if(mode==3) |
sbh9428 | 2:4c51394fb35b | 133 | { |
sbh9428 | 2:4c51394fb35b | 134 | build_table(); |
sbh9428 | 2:4c51394fb35b | 135 | } |
sbh9428 | 3:72644690e2e6 | 136 | else if(mode==4) |
sbh9428 | 3:72644690e2e6 | 137 | { |
sbh9428 | 3:72644690e2e6 | 138 | follow_table(); |
sbh9428 | 3:72644690e2e6 | 139 | } |
sbh9428 | 10:c751a0e8b7f9 | 140 | else if(mode==5) |
sbh9428 | 10:c751a0e8b7f9 | 141 | { |
sbh9428 | 10:c751a0e8b7f9 | 142 | repeatPeriod(); |
sbh9428 | 10:c751a0e8b7f9 | 143 | } |
sbh9428 | 1:5c42ec7f1aeb | 144 | } |
sbh9428 | 1:5c42ec7f1aeb | 145 | |
sbh9428 | 1:5c42ec7f1aeb | 146 | int control_t::get_mode() |
sbh9428 | 1:5c42ec7f1aeb | 147 | { |
sbh9428 | 1:5c42ec7f1aeb | 148 | return mode; |
sbh9428 | 1:5c42ec7f1aeb | 149 | } |
sbh9428 | 1:5c42ec7f1aeb | 150 | float control_t::get_target_temp() |
sbh9428 | 1:5c42ec7f1aeb | 151 | { |
sbh9428 | 1:5c42ec7f1aeb | 152 | return target_temp; |
sbh9428 | 1:5c42ec7f1aeb | 153 | } |
sbh9428 | 1:5c42ec7f1aeb | 154 | float control_t::get_P_value() |
sbh9428 | 1:5c42ec7f1aeb | 155 | { |
sbh9428 | 1:5c42ec7f1aeb | 156 | return P_value; |
sbh9428 | 1:5c42ec7f1aeb | 157 | } |
sbh9428 | 1:5c42ec7f1aeb | 158 | float control_t::get_I_value() |
sbh9428 | 1:5c42ec7f1aeb | 159 | { |
sbh9428 | 1:5c42ec7f1aeb | 160 | return I_value; |
sbh9428 | 1:5c42ec7f1aeb | 161 | } |
sbh9428 | 1:5c42ec7f1aeb | 162 | float control_t::get_D_value() |
sbh9428 | 1:5c42ec7f1aeb | 163 | { |
sbh9428 | 1:5c42ec7f1aeb | 164 | return D_value; |
sbh9428 | 1:5c42ec7f1aeb | 165 | } |
sbh9428 | 1:5c42ec7f1aeb | 166 | float control_t::get_PWM_value() |
sbh9428 | 1:5c42ec7f1aeb | 167 | { |
sbh9428 | 1:5c42ec7f1aeb | 168 | return PWM_value; |
sbh9428 | 1:5c42ec7f1aeb | 169 | } |
sbh9428 | 1:5c42ec7f1aeb | 170 | |
sbh9428 | 3:72644690e2e6 | 171 | int control_t::get_period() |
sbh9428 | 3:72644690e2e6 | 172 | { |
sbh9428 | 3:72644690e2e6 | 173 | return period; |
sbh9428 | 3:72644690e2e6 | 174 | } |
sbh9428 | 3:72644690e2e6 | 175 | |
sbh9428 | 2:4c51394fb35b | 176 | int control_t::get_table_count() |
sbh9428 | 2:4c51394fb35b | 177 | { |
sbh9428 | 2:4c51394fb35b | 178 | return table_count; |
sbh9428 | 2:4c51394fb35b | 179 | } |
sbh9428 | 2:4c51394fb35b | 180 | |
sbh9428 | 1:5c42ec7f1aeb | 181 | float control_t::calc_P() |
sbh9428 | 1:5c42ec7f1aeb | 182 | { |
sbh9428 | 1:5c42ec7f1aeb | 183 | return (target_temp-temp_sensor->get_temp())*P_value; |
sbh9428 | 1:5c42ec7f1aeb | 184 | } |
sbh9428 | 1:5c42ec7f1aeb | 185 | |
sbh9428 | 1:5c42ec7f1aeb | 186 | float control_t::calc_I() |
sbh9428 | 1:5c42ec7f1aeb | 187 | { |
sbh9428 | 1:5c42ec7f1aeb | 188 | float data=0; |
sbh9428 | 1:5c42ec7f1aeb | 189 | for(int i=0;i<10;i++) |
sbh9428 | 1:5c42ec7f1aeb | 190 | { |
sbh9428 | 2:4c51394fb35b | 191 | data+=PWM_log[i]; |
sbh9428 | 1:5c42ec7f1aeb | 192 | } |
sbh9428 | 1:5c42ec7f1aeb | 193 | return data*I_value; |
sbh9428 | 1:5c42ec7f1aeb | 194 | } |
sbh9428 | 1:5c42ec7f1aeb | 195 | |
sbh9428 | 1:5c42ec7f1aeb | 196 | float control_t::calc_D() |
sbh9428 | 1:5c42ec7f1aeb | 197 | { |
sbh9428 | 1:5c42ec7f1aeb | 198 | return -(temp_log[log_count]-temp_log[(log_count-1)%10])*D_value; |
sbh9428 | 1:5c42ec7f1aeb | 199 | } |
sbh9428 | 1:5c42ec7f1aeb | 200 | |
sbh9428 | 3:72644690e2e6 | 201 | int control_t::get_table_check() |
sbh9428 | 3:72644690e2e6 | 202 | { |
sbh9428 | 3:72644690e2e6 | 203 | return table_check; |
sbh9428 | 3:72644690e2e6 | 204 | } |
sbh9428 | 3:72644690e2e6 | 205 | |
sbh9428 | 1:5c42ec7f1aeb | 206 | void control_t::write_log() |
sbh9428 | 1:5c42ec7f1aeb | 207 | { |
sbh9428 | 1:5c42ec7f1aeb | 208 | log_count++; |
sbh9428 | 1:5c42ec7f1aeb | 209 | log_count=log_count%10; |
sbh9428 | 1:5c42ec7f1aeb | 210 | temp_log[log_count]=temp_sensor->get_temp(); |
sbh9428 | 2:4c51394fb35b | 211 | PWM_log[log_count]=target_temp-temp_sensor->get_temp(); |
sbh9428 | 2:4c51394fb35b | 212 | } |
sbh9428 | 2:4c51394fb35b | 213 | |
sbh9428 | 2:4c51394fb35b | 214 | void control_t::build_table() |
sbh9428 | 2:4c51394fb35b | 215 | { |
sbh9428 | 3:72644690e2e6 | 216 | table_check=1; |
sbh9428 | 2:4c51394fb35b | 217 | if(table_mode==0) |
sbh9428 | 2:4c51394fb35b | 218 | { |
sbh9428 | 2:4c51394fb35b | 219 | peltier->set_PWM(-1); |
sbh9428 | 2:4c51394fb35b | 220 | table_count++; |
sbh9428 | 6:c2fb5c188e8a | 221 | pc->printf(",set initial temp %d/30", table_count); |
sbh9428 | 3:72644690e2e6 | 222 | if(table_count>29) |
sbh9428 | 2:4c51394fb35b | 223 | { |
sbh9428 | 2:4c51394fb35b | 224 | table_mode=1; |
sbh9428 | 2:4c51394fb35b | 225 | table_count=0; |
sbh9428 | 6:c2fb5c188e8a | 226 | time=0; |
sbh9428 | 2:4c51394fb35b | 227 | } |
sbh9428 | 3:72644690e2e6 | 228 | |
sbh9428 | 2:4c51394fb35b | 229 | } |
sbh9428 | 2:4c51394fb35b | 230 | else |
sbh9428 | 2:4c51394fb35b | 231 | { |
sbh9428 | 2:4c51394fb35b | 232 | table[table_count]=temp_sensor->get_temp(); |
sbh9428 | 2:4c51394fb35b | 233 | table_count++; |
sbh9428 | 5:8e3b5ccf7207 | 234 | PWM_value=(float)-1+0.005*table_count; |
sbh9428 | 5:8e3b5ccf7207 | 235 | peltier->set_PWM(PWM_value); |
sbh9428 | 8:545391a4a102 | 236 | pc->printf(",build table %d/200", table_count); |
sbh9428 | 9:6ef12ac2ddc3 | 237 | if(table_count>=200) |
sbh9428 | 3:72644690e2e6 | 238 | { |
sbh9428 | 3:72644690e2e6 | 239 | table_count=0; |
sbh9428 | 3:72644690e2e6 | 240 | mode=0; |
sbh9428 | 3:72644690e2e6 | 241 | table_min=table[0]; |
sbh9428 | 8:545391a4a102 | 242 | table_max=table[200]; |
sbh9428 | 3:72644690e2e6 | 243 | } |
sbh9428 | 2:4c51394fb35b | 244 | } |
sbh9428 | 2:4c51394fb35b | 245 | } |
sbh9428 | 2:4c51394fb35b | 246 | |
sbh9428 | 2:4c51394fb35b | 247 | void control_t::print_table() |
sbh9428 | 2:4c51394fb35b | 248 | { |
sbh9428 | 2:4c51394fb35b | 249 | int i; |
sbh9428 | 2:4c51394fb35b | 250 | for(i=0;i<201;i++) |
sbh9428 | 2:4c51394fb35b | 251 | { |
sbh9428 | 6:c2fb5c188e8a | 252 | pc->printf(",%d/200 PWM: %1.3f, temp:%2.2f",i, (-1+0.005*i), table[i]); |
sbh9428 | 9:6ef12ac2ddc3 | 253 | wait_us(3000); |
sbh9428 | 3:72644690e2e6 | 254 | } |
sbh9428 | 3:72644690e2e6 | 255 | } |
sbh9428 | 3:72644690e2e6 | 256 | |
sbh9428 | 3:72644690e2e6 | 257 | float control_t::find_table(float _temp) |
sbh9428 | 3:72644690e2e6 | 258 | { |
sbh9428 | 3:72644690e2e6 | 259 | int i; |
sbh9428 | 3:72644690e2e6 | 260 | |
sbh9428 | 3:72644690e2e6 | 261 | for (i=0; i<200;i++) |
sbh9428 | 3:72644690e2e6 | 262 | { |
sbh9428 | 3:72644690e2e6 | 263 | if (table[i+1]>_temp) |
sbh9428 | 3:72644690e2e6 | 264 | return -1+0.005*i; |
sbh9428 | 2:4c51394fb35b | 265 | } |
sbh9428 | 3:72644690e2e6 | 266 | return 0; |
sbh9428 | 3:72644690e2e6 | 267 | } |
sbh9428 | 3:72644690e2e6 | 268 | |
sbh9428 | 3:72644690e2e6 | 269 | void control_t::follow_table() |
sbh9428 | 3:72644690e2e6 | 270 | { |
sbh9428 | 3:72644690e2e6 | 271 | if(table_check!=1) |
sbh9428 | 3:72644690e2e6 | 272 | { |
sbh9428 | 3:72644690e2e6 | 273 | mode=0; |
sbh9428 | 6:c2fb5c188e8a | 274 | pc->printf(",table not built\n"); |
sbh9428 | 3:72644690e2e6 | 275 | } |
sbh9428 | 3:72644690e2e6 | 276 | else if(target_temp>table_max|target_temp<table_min) |
sbh9428 | 3:72644690e2e6 | 277 | { |
sbh9428 | 3:72644690e2e6 | 278 | mode=0; |
sbh9428 | 6:c2fb5c188e8a | 279 | pc->printf(",target temp out of range"); |
sbh9428 | 3:72644690e2e6 | 280 | } |
sbh9428 | 3:72644690e2e6 | 281 | else if(period<=step) |
sbh9428 | 3:72644690e2e6 | 282 | { |
sbh9428 | 6:c2fb5c188e8a | 283 | pc->printf(",table follow end"); |
sbh9428 | 3:72644690e2e6 | 284 | step=0; |
sbh9428 | 3:72644690e2e6 | 285 | mode=2; |
sbh9428 | 3:72644690e2e6 | 286 | } |
sbh9428 | 3:72644690e2e6 | 287 | else |
sbh9428 | 3:72644690e2e6 | 288 | { |
sbh9428 | 4:7ca449fca19b | 289 | PWM_value=find_table(target_temp/period*step+start_temp/period*(period-step)); |
sbh9428 | 3:72644690e2e6 | 290 | peltier->set_PWM(PWM_value); |
sbh9428 | 6:c2fb5c188e8a | 291 | printf(",remain step: %d",period-step); |
sbh9428 | 3:72644690e2e6 | 292 | step++; |
sbh9428 | 3:72644690e2e6 | 293 | } |
sbh9428 | 10:c751a0e8b7f9 | 294 | } |
sbh9428 | 10:c751a0e8b7f9 | 295 | |
sbh9428 | 10:c751a0e8b7f9 | 296 | void control_t::repeatPeriod() |
sbh9428 | 10:c751a0e8b7f9 | 297 | { |
sbh9428 | 10:c751a0e8b7f9 | 298 | repeatTime+=10; |
sbh9428 | 10:c751a0e8b7f9 | 299 | if(repeatSide==0) |
sbh9428 | 10:c751a0e8b7f9 | 300 | { |
sbh9428 | 10:c751a0e8b7f9 | 301 | target_temp=lowTemp; |
sbh9428 | 10:c751a0e8b7f9 | 302 | if(repeatTime>lowTempTime) |
sbh9428 | 10:c751a0e8b7f9 | 303 | { |
sbh9428 | 10:c751a0e8b7f9 | 304 | repeatSide=1; |
sbh9428 | 10:c751a0e8b7f9 | 305 | repeatTime=0; |
sbh9428 | 10:c751a0e8b7f9 | 306 | } |
sbh9428 | 10:c751a0e8b7f9 | 307 | } |
sbh9428 | 10:c751a0e8b7f9 | 308 | else |
sbh9428 | 10:c751a0e8b7f9 | 309 | { |
sbh9428 | 10:c751a0e8b7f9 | 310 | target_temp=highTemp; |
sbh9428 | 10:c751a0e8b7f9 | 311 | if(repeatTime>highTempTime) |
sbh9428 | 10:c751a0e8b7f9 | 312 | { |
sbh9428 | 10:c751a0e8b7f9 | 313 | repeatSide=0; |
sbh9428 | 10:c751a0e8b7f9 | 314 | repeatTime=0; |
sbh9428 | 10:c751a0e8b7f9 | 315 | repeatCount++; |
sbh9428 | 10:c751a0e8b7f9 | 316 | if(repeatCount>=periodNumber) |
sbh9428 | 10:c751a0e8b7f9 | 317 | { |
sbh9428 | 10:c751a0e8b7f9 | 318 | repeatSide=0; |
sbh9428 | 10:c751a0e8b7f9 | 319 | repeatTime=0; |
sbh9428 | 10:c751a0e8b7f9 | 320 | repeatCount=0; |
sbh9428 | 10:c751a0e8b7f9 | 321 | mode=0; |
sbh9428 | 10:c751a0e8b7f9 | 322 | } |
sbh9428 | 10:c751a0e8b7f9 | 323 | } |
sbh9428 | 10:c751a0e8b7f9 | 324 | |
sbh9428 | 10:c751a0e8b7f9 | 325 | } |
sbh9428 | 10:c751a0e8b7f9 | 326 | control_temp(); |
sbh9428 | 10:c751a0e8b7f9 | 327 | |
sbh9428 | 10:c751a0e8b7f9 | 328 | } |