31 #include "reflow_oven.h"
37 #define MIN_WETTING_TIME 60 //seconds
48 void resetStats(
void) {
55 void printStats (
void) {
58 if (u16_endWetting == 0) u16_wettingTime = u16_tenthSeconds - u16_startWetting;
59 else u16_wettingTime = u16_endWetting - u16_startWetting;
60 if (u16_endReflow == 0) u16_reflowTime = u16_tenthSeconds - u16_startReflow;
61 else u16_reflowTime = u16_endReflow - u16_startReflow;
63 printf (
"\nMax temp: %u, Temp Overshoot: %d, Wetting time: %d (s), Reflow Time: %d (s), Elapsed time: %u (s)\n",
64 i16_maxTemp, i16_maxTemp - profiles[u8_currentProfile].i16_reflowTemp,
65 u16_wettingTime/10, u16_reflowTime/10, u16_tenthSeconds/10 );
70 i16_tempC = getCelsiusI16Temp();
71 if (i16_tempC > i16_maxTemp) i16_maxTemp = i16_tempC;
72 if (i16_tempC > profiles[u8_currentProfile].i16_wetTemp &&
73 u16_startWetting == 0) u16_startWetting = u16_tenthSeconds;
74 if (coolingFlag && (i16_tempC < profiles[u8_currentProfile].i16_wetTemp)
75 && u16_endWetting == 0)
76 u16_endWetting = u16_tenthSeconds;
77 if (i16_tempC > profiles[u8_currentProfile].i16_reflowTemp &&
78 u16_startReflow == 0) u16_startReflow = u16_tenthSeconds;
79 if (coolingFlag && (i16_tempC < profiles[u8_currentProfile].i16_reflowTemp)
80 && u16_endReflow == 0)
81 u16_endReflow = u16_tenthSeconds;
88 for (u16_i=0; u16_i <= 100; u16_i++) {
89 if (fdata.caldata.temp[u16_i] >= i16_t)
return(u16_i);
91 reportError(
"Reflow application error: Unable to find power setting for target temp");
96 int16_t i16_tempC, i16_lastTemp;
100 u16_endTime = u16_tenthSeconds + u16_targetTime*10;
101 i16_tempC = updateStats();
102 u8_endPower = tempToPower(i16_targetTemp);
105 i16_tempC = updateStats();
106 printf(
"Current temp/time: %u %u Power: %u\n",i16_tempC,u16_tenthSeconds, getPower());
108 if (u16_tenthSeconds > u16_endTime)
return;
109 }
while ((i16_targetTemp - i16_tempC) > 10 );
111 i16_lastTemp = i16_tempC;
114 i16_tempC = updateStats();
115 printf(
"Current temp/time: %u %u Power: %u\n",i16_tempC,u16_tenthSeconds, getPower());
116 if ((i16_tempC < i16_lastTemp) && (i16_tempC < i16_targetTemp ) ) {
118 setPower(u8_endPower);
120 i16_lastTemp = i16_tempC;
121 }
while (u16_tenthSeconds < u16_endTime);
131 while (u16_targetTime) {
132 i16_tempC = updateStats();
133 printf(
"Current temp/time: %u %u Power: %u\n",i16_tempC,u16_tenthSeconds, getPower());
139 void doRampDown(
void) {
147 u16_wetTime = u16_tenthSeconds - u16_startWetting;
148 if ((u16_wetTime > MIN_WETTING_TIME) && !u8_openDoorFlag) {
149 printf(
"\n\nWetting time is met, open door to aid cooling\n");
152 i16_tempC = updateStats();
153 printf(
"Current temp/time: %u %u Power: %u\n",i16_tempC,u16_tenthSeconds, getPower());
155 }
while (i16_tempC > 100);
160 uint16_t u16_endTime, u16_maxExitTime;
161 int16_t i16_tempC, i16_lastTemp;
165 u16_maxExitTime = u16_tenthSeconds + u16_targetTime*10*5;
166 i16_tempC = updateStats();
167 u8_endPower = tempToPower(i16_targetTemp);
168 if (i16_tempC < i16_targetTemp)setPower(100) ;
169 while (i16_tempC < i16_targetTemp) {
171 i16_tempC = updateStats();
172 printf(
"Current temp/time: %u %u Power: %u\n",i16_tempC,u16_tenthSeconds, getPower());
173 if (u16_tenthSeconds > u16_maxExitTime)
return;
175 i16_lastTemp = i16_tempC;
176 u16_endTime = u16_tenthSeconds + u16_targetTime*10;
179 i16_tempC = updateStats();
180 printf(
"Current temp/time: %u %u Power: %u\n",i16_tempC, u16_tenthSeconds, getPower());
181 if ((i16_tempC < i16_lastTemp) && (i16_tempC < i16_targetTemp ) ) {
183 setPower(u8_endPower);
185 i16_lastTemp = i16_tempC;
186 }
while (u16_tenthSeconds < u16_endTime);
190 void doReflow(
void) {
197 printf(
"\n\nOpen door, place board in oven, close door.\n");
198 printf(
"Turn 'TEMP' knob to 'Toast On/Bake Off'\n");
199 printf(
"Ensure that end of thermocouple is not touching\n");
200 printf(
"the board or metal. \n");
201 printf(
"Enter 'y' to continue or 'n' to exit...\n");
203 if (u8_c ==
'n')
return;
204 }
while (u8_c !=
'y');
206 u16_tenthSeconds = 0;
208 while (u8_c == ZEROCROSS) {
209 if (u16_tenthSeconds > 4)
break;
212 if (u16_tenthSeconds > 4) {
213 printf(
"\nExiting, power is not on to oven, cannot detect 60Hz cycling.\n");
216 u16_tenthSeconds = 0;
219 i16_tempC = getCelsiusI16Temp();
220 printf(
"\nStart Preheat (temp = %uC)\n",i16_tempC);
221 doRampUp(profiles[u8_currentProfile].i16_preheatTemp,
222 profiles[u8_currentProfile].u16_preheatTime);
224 i16_tempC = getCelsiusI16Temp();
225 printf(
"\nStart Soak (temp = %uC), Elapsed time: %u s\n",i16_tempC,
226 u16_tenthSeconds/10);
227 doRampUp(profiles[u8_currentProfile].i16_soakTemp,
228 profiles[u8_currentProfile].u16_soakTime);
230 printf(
"\nStart Reflow (temp = %uC), Elapsed time: %u s\n",i16_tempC,
231 u16_tenthSeconds/10);
232 doRampUp(profiles[u8_currentProfile].i16_reflowTemp,
233 profiles[u8_currentProfile].u16_reflowTime);
234 printf(
"\nStart Reflow Hold (temp = %uC), Elapsed time: %u s\n",i16_tempC,
235 u16_tenthSeconds/10);
236 doHold(profiles[u8_currentProfile].i16_reflowTemp,
237 profiles[u8_currentProfile].u16_reflowHoldTime);
242 printf(
"\nStart Cool1 (temp = %uC), Elapsed time: %u s\n",i16_tempC,
243 u16_tenthSeconds/10);
247 doRampDown(profiles[u8_currentProfile].i16_coolTemp,
248 profiles[u8_currentProfile].u16_coolTime);