In part one I dealt with the very basics: fan control, buttons and the display.
Now it is time to attack the business end of this device!
Safety warning / disclaimer:
Please understand that operating a device powered by line-voltage, especially if it is open and you may stick your fingers inside (which you really really shouldn’t), is a potent source of all sorts of bad things of a final nature.
- You may severely burn your flesh (not just medium, but well done)
- You can start a fire and burn down your house
- You can electrocute yourself, then start a fire and burn down your house
I think you get my point.
If you still insist in opening up such devices, there is one rule to rule them all:
Always make sure the power cord is unplugged, before you stick your fingers inside the device. Check for that fact repeatedly. Don’t allow your brain to trick you into thinking that you’ve unplugged the cable some time ago, always check, double check, triple check. If you leave your workplace and come back or you got distracted by something, check the power cable for unplugged-ness again. If you know you cannot trust yourself, cover the power-socket of the device with tape. Then check that the tape is still in place…
BE PARANOID! BE A SAFETY NAZI!
You’ve only got one life – and there is no backup to restore.
Step 8: reading the thermo-couple
The analog reference voltage for the ADC has to be switched to EXTERNAL (about VCC / 2). This results in readings that are in °C without doing any conversion. I have had to add an empirically determined offset value to that number. Maybe due to the fact that I calibrated against a sensor in front of the nozzle.
Step 9: temperature control
The heater of the device has an output power of about 650W, packed into a very small space. It will heat up very quickly, almost too quickly to react if something goes wrong. And if for some reason the fan isn’t running, the heat will not get out and build up until all you care about is where the next fire extinguisher is.
Don’t operate the heater without a working temperature readout. Make sure your code doesn’t lock up or spends too much time doing other stuff when the heater is on.
It’s a very good idea to add heater-on feedback by means of the 7-segment display.
Keep a close eye on the temperature readings and be ready to cut power at any time. To help the heater cool down, you can blow air into the back of the wand, so it goes back to a ‘sub-critical’ state.
I’ve implemented PD control for the heater. It works reasonably, but needs some more tuning of the P and D constants. The error signal changes the PWM duty cycle that drives the heater. Currently PWM resolution is not great (all done in software), so the smallest on-time of the heater is still a bit too large. I may switch to hardware-driven PWM later, which should help a bit.
if (REEDSW_OPEN && (temperature_setpoint >= MIN_TEMPERATURE)) { // !! DANGER !! FAN_ON; heater_duty_cycle_tmp += ((float) (temperature_setpoint) - (float) (temperature_inst)) * (float) (T_LOOP_P_CONST) + ((float) (temperature_inst_previous) - (float) (temperature_inst)) * (float) (T_LOOP_D_CONST); if (heater_duty_cycle_tmp < 0) { heater_duty_cycle_tmp = 0; } heater_duty_cycle = (uint16_t) (heater_duty_cycle_tmp); if (heater_duty_cycle > 255) { heater_duty_cycle = 255; } if (heater_ctr < heater_duty_cycle) { set_dot (); HEATER_ON; } else { HEATER_OFF; clear_dot (); } heater_ctr++; if (heater_ctr == 255) { heater_ctr = 0; } } else { HEATER_OFF; clear_dot (); }
One major advantage compared to the stock firmware is that now the device shows the current temperature, so you see important stuff like overshoot and fluctuations if they occur. Previously the device would only show its temperature set-point, hiding away all the important information.
Continue reading: Part III