Microprocessor Control for the Oven Based Coffee Roaster

This page describes the electronic hardware aspects of building the roaster. Programming it is elsewhere. The mechanical and electrical aspects are on a separate page.

Cannibalising

The controller is built from the controller I built for the popper-based roaster (and shown to the left). That controller is described in detail on a separate page.

This means that there are several aspects that I wouldn't necessarily adopt if building from scratch - in particular, the board layout is not as optimal as it would be, some connection wires are excessively long, and others are extended untidily.

Processor

As covered on the main popper roaster page, the controller is built round a Microchip PIC (specifically, a 16f877a). This is an 8-bit microcontroller, with on-chip multi-channel 10 bit analogue-to-digital-converter, lots of relatively high-power IO pins (minimising external componentry when interfacing to external devices), flash program memory (so can be repeatedly erased and reprogrammed during code development), and a RISC assembly language that's relatively easy to learn. It also has an assortment of timers, peripheral interrupts, a serial module for easy I2C or SPI interfacing, and an interrupt-driven UART module. In short, a highly capable microcontroller on a single chip.

Furthermore, Microchip give away an assembler-based IDE (MPLAB)for windows platforms, and there are various ways of programming the chip from within Linux. When I built the popper-based roaster, the Microchip IDE was the sole reason for me keeping a running windows machine. Now, I'm pleased to say, that's no longer necessary - and most of what you need can be easily found for free at www.gnupic.org. I use the gnupic utilities project gputils to program in assembly, and details of that process are on the programming page.

Boards

Main Board

This is the main board. As noted, it's a mess.

The general layout is as in the popper roaster:

The coils of wire are where I had wires already fitted, but I'm now not using those pins. For now, the wires remain in place, in case I want to hook something up to them.

Most of that is superficially as it was before, though are changes regarding what is connected to what pin - I've moved the buttons around, and the LCD is now in 8-bit mode (using 11 IO pins) when it was previously in 4-bit (7 IO pins). The LCD backlight is now not under active control

Main Board Additions

There are some additions to the main board.

Since building the popper roaster, I've become convinced of the benefits of in-circuit programming (ICSP), so I've rejigged the board to accommodate this. These connectors by the corner of the chip connect to the programmer and let me reprogram the PIC in place. That means I don't need it in a ZIF socket any more, and makes the code-burn-test-curse-recode-reburn-retest-recurse-repeat loop faster.

Other than adding the connectors for the programmer, the only real change to the board is that the reset button circuit is now a little more complex (but still only two resistors and a schottky diode). This is one case where the board is now untidy - to fit with the way my tracks are cut there's a resistor - diode joint hanging in space above the board

The other change is to the clock circuity. Originally (first popper roaster) this was a 256kHz-ish RC oscillator, then it was an 8-pin chip and a 32768Hz crystal, giving timing accuracy at least as accurate as any digital watch. Now it's a new chip (the one that is apparently unmarked in this photo), which is an I2C real time clock with automatic battery backup (the CR2032 cell in a vertical holder at bottom left). Again, it runs off a 32768Hz clock crystal. The two wires running straight down the photo to the right of the chip are the I2C clock and data lines. (The bigger chip is just a divider chain - it chops the 32768Hz down to 256Hz which is the clock signal I want at the PIC.)

Note that the circuit as shown does not run (the oscillator does not start up). The chip needs an external pull-up resistor on pin 7. I didn't notice the requirement initially and spent a week trying to work out why my i2c commands to start the clock running weren't working, when actually it was the oscillator that wasn't working.

I don't actually have any good reason for the roaster knowing what the time and date is, but I came across the chip so thought I'd add it. It also has 56 bytes of NV SRAM onboard, and I don't know of anything to do with that either.

I chose the battery size because I had some of those cells lying around. According to the data sheets, that cell will keep the clock running accurately for more than 45 years.

This is the i2c bus data line while the microcontroller does a read of the time from the RTC chip. The RTC chip has a device address of 1101000. The microcontroller first writes one byte = 0 which the RTC chip takes as a register pointer. It then does a read and the RTC chip sends back the time - in this case it was ?:36:37.

I think the glitches half-way through each bit are when the clock line switches. I should probably investigate and deal with them, but everything works so I can't be bothered. Actually, the bus is running at 100kHz and other things on the bus work at 400kHz also, though the RTC chip won't respond when talked to at 400kHz. I'm assuming the noise is not too bad if it is able to run at 4x the frequency I need.

This trace is also on youtube in glorious moving pictures! where you can see the seconds counting up (but without the explanatory annotation).

Secondary Boards

The fan in the oven and the rotisserie motor both want mains voltage but low current (very low for the rotisserie). They are switched by relays on a secondary board. The relays are just ones I had lying around, and they are quite current-hungry, so they are switched by transistors. The diodes over the top protect the transistors from the spike when they try and switch off the relay coils. The LEDs show if the relay is energised. This is not particularly useful when the whole lot is shut up inside the roaster, but it helps while testing.

This board has mains voltage on it - a good reason for it being a separate board (though it could, of course, escape along the wires to the main board if anything shorts).

Other Magic

For the popper roaster, I built a Max232-based level shifting thingy to convert the 5V TTL signals from the chip USART to RS232 levels so the roaster could talk to a PC.

The new controller has a much tidier system, courtesy of the nice chaps at FTDI. I say nice chaps, because they have several things going for them: 1: a very handy product (more about that in a moment), 2: they properly support linux, with decent linux drivers for their products, 3: they will sell direct to consumers, in quantities of single units (see their shop. They are also based in the UK, which I like.

So what is the product?

Apparently a usb lead with a 3.5mm stereo audio jack at the other end. It looks like just a lead - no box or dongle on it - but actually, it talks 5V TTL level with Tx, Rx and Gnd on the audio jack, and normal usb on the usb end. So I can wire a standard stereo jack socket direct to my microcontroller and using the magic cable plug straight into a usb port on the PC. There's more details on FTDI's product page, but it's a FT232RQ USB to serial UART interface chip ( datasheet here) embedded within the moulded usb connector.

Assembled


The main board and relay board assembled onto the back of the control panel (which is just screwed onto blocks of wood for testing / code development).

The main element SSR is at top right, the green board is the back of the LCD 16x2 display. The toggle switches let me take control of things individually - each element, the fan and the rotisserie motor goes through a toggle switch so I can force it either on or off or leave it under the control of the processor. I'm not putting the mains wiring in until the electronics are at least basically functional.

The program running is just a test routine - the PIC is counting up on the top line at the rate of 20 per second, and the bottom line clears / increments / decrements as you press buttons.

The little board off to the bottom left is a power regulator (not the final one - just for testing). The board to top left is my programmer at the time (a Warp-13a from the sadly now-defunct Newfound Electronics) hence the purple wires heading off to its vicinity. Since the photo, I've given up resisting and bought a Microchip PICkit2 USB programmer, because the Warp does not support newer pics.

The SSR has a heatsink on the outside of the panel. It's probably not necessary - it's a 50A SSR delivering about 12A while fixed to a sizeable aluminium panel, but I had the heatsink already, so decided it wouldn't hurt.

The aluminium panel, switches, neons, SSR and about 10% of the components in these pictures are from ebay. All remaining components except the RTC chip and associated crystal are either cannibalised from the previous roaster controller, or extracted from my bits box.

and this is as far as it has got ... tune in again for another thrilling installment some time.


back to the main oven roaster page
back to the top roaster page
back to Ian's contents page
back to www.astounding.org.uk top contents page

To comment on anything (please do) email ian@astounding.org.uk