A slow pwm heater control

gengis

New Member
Picaxe Range Control - theory of operation

I added a picaxe to control the heating element on the stove the last time a control failed. Its been a few months now and I'm pleased with the result (especially the flashing tri color LED which lets me know what is happening from across the room). \

The hardware:
There's a ~4.5 volt power supply the 78L05 is the TO92 version of the usual 78 series linear regulator and a small signal diode to drop an additional .6V. There is a triac to control the element that is turned on and off with a zero crossing opto coupler directly switched by the axe. A tri-color LED is also controlled by the axe and indicates heating (red) coasting (green) and full power (magenta - red/blue).

A solid state relay would replace the triac and coupler, but would cost a little more.

The code used:
The program goes through an initialization routine that gives the mechanical "safety relay" time to pull in, then turns the heater on full power for about 5 seconds to preheat the element. The potentiometer ADC is read into an 8 bit variable and if it is below 10
it goes into a minimum warming stage where the PWM is arbitrarily set for ~10% "on" time. If it is higher than 10 it goes into it's pulse width modulation routine. 10% is perfect for keeping coffee hot.

The very slow software pwm works by pre loading variable b1 with zero, and b2 with 255. Then the potentiometer variable is added to b1 and subtracted from b2 - this establishes the on-off ratio.

If the potentiometer setting is at maximum, it branches to a high power setting where the element is turned on fully with no PWM modulation, and the blue and red LEDS are turned on together.

If the pot setting is between 10 and 254 it modulates the power by turning the heater off and on and flashing the green or red led respectively. (The led itself is in one of the tricolor, "high flux," four pin, square package, very bright, and has ~130 degree beam spread) There's a pair of for/next loops to repeat the (otherwise) 255 millisecond on/off pwm time and stretch it by a factor of ten. I did that because I wanted to see the led without fast flickering between red and yellow, and the heater has a great deal of thermal lag, so it maintains a pretty constant temperature even when fired in ~2 second bursts.

The mechanical arrangement is a small piece of aluminum sheet stock with parts bolted to it with flat head machine screws in counter sunk holes. The potentiometer panel screw secures the aluminum chassis to the stove. (The reason for using flat head screws - not enough thread on the pot to work unless the chassis is flush with the panel)

It is hard to find sensitive (low power coil) relays that handle high current contacts (spring tension on large contacts has to break the current quickly to avoid arcing, and the relay armature has a lot of mass). There's an "off label" use for zero crossing opto isolators: they can often handle the relatively mild current a 120 volt relay might take. A six watt, 120 volt coil will need less than 100 ma, and a typical opto can handle close to an amp. So the relay could be switched directly with the isolator. Makes more sense than increasing the DC supply to produce the extra ~6 watts (or a half amp at 12 volts).

The safety relay does interrupt power, in the event the circuit is energized and calling for power, as the switch is switched off. That isn't ideal. Ideally, I'd want the safety relay to never interrupt power but let the triac or solid state relay do all the heavy lifting. That would mean coming up with a way to delay the safety from releasing until the picaxe power supply caps were completely discharged. If I did that, the safety relay could be much smaller physically. But since I had these large 35 amp relays I didn't get that fancy.

The green LED is always off when the red one is on - so a single NPN transistor could be used to drive the green by pulling it low when the red led/heater axe pin is high - and free up one output to use for something else - like an audible chirp, every five minutes, to remind me the range is on. Nice idea, but thought of it too late.

This is mains operated. My stove is old and the power is two 120 volt lines with a single ground. Modern code requires a four wire circuit. The 120 VAC convenience outlet on the range is grounded to the chassis as are the oven and surface lamps - so I'm not doing something that isn't already done. The 'axe circuit 4.5 volt return is also chassis grounded - but for control of EMI - won't work properly without a ground.

If you don't understand the hazards, don't build mains operated equipment. I've worked in electronics all my life, and worked a stint in power line construction, and build Tesla coils as a hobby, so a range control is something I'm comfortable with.

There's another hazard here - temperature and wire insulation. The circuit breaker for the range is 40 amps that can light up a shorted wire and cause a fire. The ambient temperature in the control housing can be high, and should be considered in sizing the parts, heatsink for the triac, and wire gauge and insulation type. I used only 14 AWG wire (same as the manufacturer) for the power wires. I couldn't locate wire with braided fiberglass insulation, like the OEM stuff. No great loss in my opinion, because I already found liquids can penetrate the insulation and cause leakage. I did find some silicone insulated wire in a surplus catalog (company called MECI) and got that. It is commonly used in big industrial motors, and will withstand a match flame indefinitely - and takes 20 seconds for a propane torch to start burning the insulation. The insulation won't support a flame, it just starts sublimating, almost no smoke, and loses mass and gets weak.

Another area for concern: The "snubber" circuit across the triac. The cap should be AC rated for 240 volts or a DC, non-polar, 600 Volt cap. The 47 ohm resistor should be a flame proof type in case the cap shorts. I've used 1/4 watt carbon film in those applications without a problem - but may be wrong about that. The only time I did see a cap failure and 120 VAC was applied to a 1/4 watt 100 ohm resistor the resistor flashed and opened - didn't even singe the paint it was so fast. But this is 240 volts and if an arc started, and was sustained, it could light a fire. Another good reason to use a solid state relay - let someone else deal with the design safety.

BTW. When I roll my own SSR's and things of this sort, I use epoxy that is filled with fine quartz sand ("sand box" sand from the hardware store). It is a great insulator, it conducts heat better than epoxy, is a strong aggregating filler, and is cheaper than epoxy. Works better than plain epoxy as a wood adhesive too - clamp the pieces and the sand bites into the wood.

Another time saving idea: depending on the thickness and type of aluminum, counter sunk holes can usually be pressed into the metal without resorting to a counter sinking bit and drill motor. Punch the hole you want, put a flat head screw through the hole, back the head against an anvil or suitable massive chunk of iron, put a short length of steel tube over the threads and whack it with a hammer - instant counter sink. For #6 screws, and light metal, I find a 1/4" hollow shaft nutdriver will substitute for the steel tube and a few taps with a hammer.

The LEDs I used are an Ebay item from "Superbrite" in Hong Kong. They are pretty amazing. The light output is great even when running on 3 volts, cost was low ($14/20 pcs) and included shipping. The beam angle is very wide - 120 degrees to the half power points. Mounting was a bit of hassle with the high flux package, but the performance more than makes up for it. Their specifications say that 3.4 volts is typical for the blue and green LEDs, but the blue is dropping 1.1 in the circuit and the green 1.7 - while the red is at 2 volts.

Code:
'PICAXE REPLACEMENT FOR "INFINITE RANGE CONTROL"
' FOR ELECTRIC STOVE
     pause 100      'gives safety relay time to pull in
     low 4               'low on pin 3, element 'on'
     high 0              'turns off blue LED
     pause 5000          'cold start 5 sec heat
     high 4              'high on pin 3, element 'off'
main:     
     readadc 1,b0        'read 8 bit analog value, pin 6, into b0
     if b0 < 10 then lopwr    'go to minimum heating routine
     if b0 >= 10 then set1    'load starting PWM values in
set1:
     b1=0           'set up slow pwm values "ON"
     b2=255         'set up slow pwm values "OFF"
     b1=b1+b0       'readj value based on pot position "ON"
     b2=b2-b0       'readj value based on pot position "OFF"
     goto heat
lopwr:
     b1=25               'sets minimum heat @ ~10%
     b2=230
     goto heat
hipwr:
     low 4               'turns on power 100% + red LED
     high 2              'turns off green LED
     low 0               'turns on blue LED
     pause 10
     goto main
heat:
     if b0>=255 then hipwr    'set heating to 100% on if pot full CW
     high 0              'turns off blue LED, goes into SPWM routine
     low 4               'turn on, low on pin 3 red led on
     high 2              'pin 5 high green led off
     for b4=1 to 10      'for/next period stretcher 'on'
     pause b1
     next 
     high 4              'pin 3 high
     low 2               'pin 5 low green led on
     for b4=1 to 10      'for/next period stretcher 'off'
     pause b2
     next 
     goto main
 

Attachments

fernando_g

Senior Member
Good job, and some excellent tips!

I liked particularly the one which adds sand to the epoxy, which makes an excellent adhesive with electrical insulation characteristics and good thermal properties!
The instant countersink idea is also extremely valuable.

All in all, a well described and useful project.

There is a Motorola app note, which provides the snubber considerations for optocoupler-driven relay coils. Let me see if I can find it.
 

westaust55

Moderator
Picaxe Range Control - theory of operation


BTW. When I roll my own SSR's and things of this sort, I use epoxy that is filled with fine quartz sand ("sand box" sand from the hardware store). It is a great insulator, it conducts heat better than epoxy, is a strong aggregating filler, and is cheaper than epoxy. Works better than plain epoxy as a wood adhesive too - clamp the pieces and the sand bites into the wood.
The idea of adding fine sand to epoxy for electrical applications is not new but certainly worthwhile.
Back in the 1970's and possibly earlier, GEC out of England (now part of that company is Areva), used epoxy with fine silica sand for High Voltage electrical cable jointing.
 

gengis

New Member
Thanks for the tip fernando_g I found this: RC Snubber Networks For Thyristor Power Control and Transient Suppression AN1048/D

A repository of Motorola application notes: http://www.bychoice.com/motorolaApps.htm

In the 70's I worked for a power supply manufacturer. We had a contract to wind some replacement transformers used in old tube type military gear. The original we dissected had a high temperature wax impregnation.

The transformers were potted in tin plated steel cans (hermetic seal). We used a polyester compound for potting and added sand cause the stuff was pricey. Somehow a steel can got some oil on the inside and the polyester didn't adhere well when it catalyzed. You could sqeeze the can and hear bits of sand. The owner of the company promptly dubbed them our "true grit" line of transformers.
 

garyboy

New Member
Thank you. (saved me a lot of time/effort)

I was all set to design my own heater control for a borosilicate glass annealing kiln I am building. Instructables has a J type thermocouple Picaxe circuit under the heading "automate your science projects" It can also be found by searching Instructables for "Picaxe" Now I can combine the two circuits/programs to have a temperature controller with FEEDBACK! When/if this gets done I will post a thread.

On a side note I have been amazing my glassblowing peers by creating digital control circuits OVERNIGHT for my boss. He is just stunned that so much can be done with IDENTICAL circuits! (a servo controller is the same as a LED blinker is the same as a stepper controller aside from the programming and what gets plugged into it)

They think I'm a genius! (little do they know it's all the same circuit with "borrowed" code)

Thanks Picaxe! (and all developers who share their projects)

Gary
 
Last edited:
Top