I've been experimenting with automatic power control for a HG+BM
'Corretto' roaster. I wanted to be able to control the power from a
computer so I could produce a consistent roasting profile. I also
thought it would be fun to try and put it together

The first thing I tried was using X10 control switches. I talked to
the people at smarthome.com.au, and they told me their switches could
handle 10A, that they were based on solid-state switches and that they
could be switched on and off quite quickly (several times per
second). I thought that I could control the power level by switching
on and off the HG via a X10 switch to give a percentage load. For
example, to get 80% power I'd switch it on for 0.8s then off for 0.2s.

I bought some X10 gear, and tried it out. Unfortunately I found that
while the HA103 could indeed do 10A, it would only switch quite slowly
(best I could get was about one switch every 2s). The HA114 switches
faster (about 5 times per second) but only does 5A. The loud clacking
sound each time they switched also made it obvious that they used
relays, which would probably wear out quite quickly.
So I gave up on the X10 gear, and started looking for other ways to
control the power. I asked an electrical engineering friend of mine
(Paul Mackerras) and he thought I'd need a custom circuit. He very
kindly designed a circuit for me, and built a power control device.

The device takes 240v in, and puts out a reduced amount of power
controlled by a serial port. To use it, you attach to the serial port
at 9600 baud and write the percentage power you want (so to get 80%
you write "80%\n"). I bought a cheap USB serial adapter from eBay
(just $3.87 including delivery!) and connected it to my laptop, giving
me USB control over the power level.
Pauls circuit works by using an opto-coupled triac with a PIC
micro-controller. The PIC looks for the zero crossing of the AC and
switches the power on based on a delay of a calculated number of
milliseconds after the crossing. This allows it to very accurately
deliver the amount of power requested (it has a little lookup table in
the PIC which maps the percentage power to the timing of the on-off
signals sent to the triac). Paul also set it up to monitor DTR, so it
only switches on when DTR is set. This provides some additional safety
that to ensure you don't switch on the power to the HG when you don't
want to.
Another friend (Hugh Blemings) has kindly drawn up the circuit
using gschem (after my attempts were getting nowhere!), which should
make it possible to produce a nice PCB layout for future versions. The
prototype Paul built uses veroboard. Hughs circuit if available as a
PDF and a raw gschem circuit here:
http://samba.org/tridge/pyRoast/ppppd.pdfhttp://samba.org/tridge/pyRoast/ppppd.schI wrote a little python app to control the whole thing.

as you can see, it is heavily inspired by the CoffeeSnobs
RoastMonitor java app, with the addition of some code to do automatic
power control using a (slightly modified) PID control loop. It also
has a little simulator built in which has been tuned to roughly match
the roast profiles I get in my roaster. That makes it easier to play
with the PID control without wasting a lot of beans

The code for the above is available at
http://samba.org/tridge/pyRoast/ if anyone wants to take a look. It
also contains a C prog (RawMeterReader.c) that can talk to the
CoffeeSnobs DMM to read the temperature. It only works on Linux for
now (I'm running Ubuntu Karmic).
The resulting setup looks like this:

notice the little power control box in the foreground, and the pyRoast
application running in the background. The two USB cables are for the
power control and the link to the DMM.
One problem I had initially was I kept melting the temperature
probes. The solder in them melts at below 200 degrees, and the inside
of the bread machine gets hotter than that, so the solder soon comes
loose and you get very unreliable temperature readings. The problem
was caused by initially having the temperature probe inside the bread
machine, like this:

This not only caused the probe to melt, it also meant that it could
move around a fair bit while roasting. The solution was to put the
probe into the side of the bread machine

with it going through the wall of the machine as shown in the full
setup picture above. It doesn't melt any more, and it is held much
more firmly in place.
I'm still playing with the ideal roasting profiles for this setup, but
the power control is working very well. It was also a lot of fun to
build, and the coffee tastes great!
Please note that you should only try to build the power control
circuit if you have the right qualifications and you understand the
circuit. We're thinking of submitting it to something like SiliconChip
magazine in the future, and maybe someone will even make a kit, but
meanwhile don't try it unless you really know what you're
doing. Building 240v circuits (even ones that are opto-isolated) is
not for beginners.
I'd also like to say a big thank you to CoffeeSnobs for all the ideas that
went into the above. I wouldn't have tried to build this without seeing
all the great results everyone else got with a Corretto roaster,
and seeing the nice CS Java RoastMonitor app.