Saturday, 28 June 2014

Circuit for a laminator controller and PCB manufacture of the same

I have, for about a month now on and off, been working on the controller board for the toner-transferring laminator. This involved buying some new tools including a drill press add-on for my Dremel multi-purpose tool, a chuck for the Dremel, and a collection of drill bits in various sizes.

First of all, here is a picture of the finished product:


But to actually make a PCB I needed a way to control the laminator without the controller PCB - a PCB-inspired Catch-22! To break the cycle I first made up the controller circuit on breadboard.

I “cheated” here somewhat and used a breakout board for the MAX6675 (PDF) thermocouple SPI IC. The board also came with a “Type K” thermocouple, which was going to come in handy. The relay for turning the heater on and off, too, was contained on it’s own little PCB which also contained a simple transistor driver. This was essential really, as there is no way I’d want mains current flowing around the breadboard. One of the key things I wanted to do was add a display to the controller board - something to show the current temperature. And I wanted a way to set the target temperature too, instead of simply fixing it in code. Luckily I had exactly 2 little displays, each one with 2 half inch 7 segment LED displays, enough for 3 digits and a “C". To set the target temperature, two push buttons (up and down) are also required. For what it’s worth, if I ever want to use the laminator to laminate paper, I can simply set a lower temperature.

Driving the display is fairly simple. Since the 28pin ATMega8 has a large amount of IO pins, the display can be driven directly; 7 pins to light an LED segment, and 4 pins to select a digit. Using multiplexing, it is simple to loop through each digit lighting the appropriate segments.

After getting the breadboard controller working and writing the code, it was time to make up the PCB. This required drawing up a schematic to match the PCB:


The “production” controller board is designed to be powered from a mains adapter PSU with the standard barrel connector, running at anything upto about 12V, with 5V to the AVR and other parts being supplied by the venerable 7805 (PDF).

Note that in this schematic the relay PCB circuit has been included here because I wanted everything on a single board. I actually bought 3 of these little relay PCBs (each one with 2 relays) and dismantled one of them to salvage the relays and a few other parts. This was actually cheaper then buying the relays individually! A simple transistor switch is used to provide the relay with enough current to turn on and off. The venerable 2N222 was chosen, only because I had some in the parts drawer. A diode is used to prevent back EMF from feeding back into the MCU.

Also, the MAX6675 is included directly, because (once again) I wanted to fit everything on a single board. I knew this was going to present me with a challenge, since this is Surface Mount Technology part, and I had never dealt with these before. In a way this makes the board double sided, since components are on both the top and bottom of the board.

One nice thing about the circuit is I managed to keep the serial transmit pin free. This means my controller firmware can transmit temperature information on the serial port. At some stage, when and if I can be bothered, this could even be used to produce realtime temperature graphs on the computer display. For now it is just a handy way to see the temperature the laminator is running at without glancing at the controller board.

The software I run on my board, which is fairly trivial but has a few interesting elements, is available on github. It uses the SPI routines described in a previous post to read the temperature, before doing some bit mangling to extract the actual value from the SPI data. See the data sheet for a description of the packet format. The most interesting aspect (for me) is that it uses timer interrupts to multiplex the display. Interrupts are one of the few remaining AVR features to explore. Additionally, the EEPROM within the MCU is used to store the target temperature, so it does not need to be reconfigured each time the board is board is powered up. I’m also quite pleased with how the buttons to set the target temperature operate; to differentiate the target temperature from the current temperature, the display flashes when setting the target temperature, much like when a LCD watch has its time changed. This kind of control application is the perfect example of why MCUs have become so widespread in the world.

The software also contains a couple of “safety features”. If the temperature can’t be read for any reason, the heater is immediately turned off. And it is not possible to set a “silly” temperature as the target.

The software is fairly good at keeping the temperature constant, but not perfect. Temperature variance is in the order of +/-5C around the target temperature. This is because the temperature continues to increase slightly after the power to the heater has been removed, presumably because the thermocouple does not adjust to the changing temperature fast enough. Anyway, it is good enough and many times better then the bimetallic thermostat the laminator shipped with.

The next step was to layout the PCB:


This presented me with some additional challenges related to the fact that this PCB was not going to be professionally produced. Instead it had to work to home-made PCB tolerances. I made the tracks wider (15mil vs 10mil) and also made the pads a little bigger etc. A further challenge is that this was a single sided board I was making. To work around routing difficulties caused by the fact that all tracks must be on a single side, jumper wires are used on the component side. Finally, to save the Ferric Chloride from being “worn out” too soon, unused areas were filled with copper instead of being etched out.

Note the nice thick tracks around the relay at bottom centre. This is because of the high mains currents that are required to drive the heater in the laminator. Also, since it is on the track side of the board, the SMT device is shown in white.

The PCB is 10cm by 8.5cm.

For various reasons, but especially a problem with the filled out areas, I am now seriously looking at alternatives to the gEDA suite. The PCB program in particular is very tedious to use and is in no way “modern software”. Therefore I’m going to look at two alternatives: KiCAD and Eagle. Hopefully one of those will better suit me. It is annoying though; generally I don’t mind gschem (the schematic capture part of gEDA), and learning a new tool will take a long time - time that I could be using working on actual projects. Plus I will have to remake my custom schematic symbols and PCB footprints. It also makes me a bit sad because I like the fact that gEDA is open source.

So anyway, once I had the laminator being temperature controlled with the breadboard circuit it was time to produce the PCB! This required a number of steps, which I will detail in case anyone else is interested in making their own PCBs. I took some photographs as I was going along, but note that some are not of the finished design since I made a number of mistakes along the way.

1. Print out the PCB track design on a laser printer. You cannot use normal printer paper - it is too thick and will not transfer the toner nicely. Instead I used magazine paper. It must be very thin. I used paper from a free shopping (advert) magazine; decent paid-for magazines will again be printed on paper that is too thick. To actually load it into the printer tape the magazine paper to a piece of normal printer paper and use the manual feeder.

Worth saying this twice: make sure you are printing out the design mirrored.

It might take a few attempts, but eventually you should end up with something like this:


But hopefully a bit better, since this was discarded due to the amount of dropouts. Then you will need to trim the paper to the size of the copper clad board. You can use a craft knife for this, but I prefer just using scissors.

Remember to print the design out mirrored! Or it will be useless, as I found out to my cost.

It’s quite likely that the print won’t be perfect and there will be missing toner. I generally have a few attempts and choose the best one.

2. Cut the copper clad board to size. There are various ways of doing this. Some people use a hacksaw, some people use an electric saw. My preferred method is to score the copper side of the board with a craft knife and a metal ruler, cutting through the copper and into the fibreglass or other PCB material. After scoring the board, my low tech solution to snapping the board involved clamping it to the edge of the desk and bending it. This worked surprising well, didn’t make any horrible fibreglass dust and resulted in a nice break. A quick sand with some fine sand paper smoothed the edge of the board along the break.

3. Bring the laminator up to the required temperature. I set my controller board to 175C, which seems to be a good temperature for toner transfer. Have some means of holding a hot piece of PCB in your hands, like a thick cloth etc.

4. The tricky part, then, is to place the paper onto of the copper clad board (print side down obviously) whilst simultaneously feeding it through the laminator. The first few times through the laminator the paper will “flap about”; only after the board has heated up will the toner start to melt and stick the paper to the board. It takes some practise to line the paper up with the board precisely. It is obviously not possible to tape or glue the paper to the board.

Here is a very poor quality shot of the transfer in progress. You can just see the controller breadboard circuit at the right hand side of the picture:


 5. After feeding the board through about 5 or 6 times the board will be very hot and the paper will be stuck nicely to the copper clad and you will be able to see tracks through the paper. This means everything is going well. Feed the board through a couple more times “for luck”.

6. You can leave the board to cool down on its own, or just throw it straight in a sink of warm soapy water.  In any case, get the board and paper wet to the point that the paper is waterlogged. The paper should then just “fall off” when you put it in under the tap. The result should be a piece of blank paper in one hand and a toner transferred copper clad in the other:


 7. Your PCB may well have a strange white fluffy residue on it. This is the remains of the paper. Some people rub this off, but I prefer to leave it on as it provides yet more resistance to the etchant. Here’s a picture of one of my boards prior to etching. You can clearly see the “white fluff”:


At this point you can fix any small print or transfer errors with a marker pen. This will block the etchant from getting at the copper, but probably not quite as well as the toner would.

8. Now the fun, but tedious part. You must wear rubber gloves, and be in a properly ventilated area. FC is kind of dangerous, but not overly so, and not if you are careful and know what you are doing. It WILL stain almost anything it comes into contact with, and it will hurt if it gets on your skin. Smoking while etching is also probably not a good idea!

I have no clue about other etchants as I’ve not used them.

I have my etchant stored ready to go in a plastic “click lock” food box, with the unused FC in the bottle it came in. Gently place the board in the FC. Etching took, for me, about 20 minutes. Occasionally tip the box backwards and forwards to “agitate” the liquid and ensure an even etch. In general, the frequency which you should agitate and examine the board should increase as you get towards the end of the process. It’s very annoying to over etch a board, but equally painful to under etch. Towards the end of the etch, I found it helped to rub the board gently with a rubber-gloved finger to coax the etchant along.

9. Once the board is etched, clean of all the etchant and clean up the mess you’ve made. FC can be used a few times before it is “exhausted” and needs to be safely disposed of.

Here’s a picture of one of my boards after it’s been etched. This is the first board I made, and you can clearly see some areas which are over-etched. The boards got better as I went along. This particular board's bigger problem was that I forgot to mirror the printout:


10. After etching comes the drilling. My Dremel drill stand is really not very good, but I managed to get through this task relatively quickly. Here’s the final board after drilling, with a few components seated for testing alignment prior to soldering:


You can see that this board is quite a bit better then the first one. This is because I watched the board very closely in the final stages of the etch, pulling it out frequently.

11. The final step is of course the soldering. This is much tricker then soldering a professionally made PCB, since there is no solder mask and no plated holes. Here’s a picture of the back of the finished board:


You can see some sloppiness. I blame my very cheap soldering iron for this. Soldering the SMT MAX6675 was quite difficult, but I think I would do better next time. The best solution to this kind of operation, without having any solder paste or PCB ovens, is to flood the pins with solder and then suck off the excess. Even with this little trick, the IC is still not quite aligned correctly.

As usual, I tested as I went. First with the MCU and the ISP programmer header, then the display and relay, before finally the temperature sensor.

In use the board behaves as well as the breadboard, but of course is much smaller and self-contained. I did notice the LEDs on the 7 segment display are not especially bright, but they are bright enough to be read clearly.

There’s not much more to do really, except find a way to mount the PCB to the base of the laminator so I can move the equipment about “as one piece”, and perhaps tidy up the code a bit more. I would also like to investigate how to better deal with the errant temperature readings that occasionally come from the MAX6675 and make the code ignore these erroneous readings, but apart from that I think this little project is done!

Along with the code, the schematic and PCB design can all be found on github.

I’m very pleased to now be able to make up my own little PCBs. I will continue to use botech for the complex circuits, but simple things, perhaps designs up to twice the size of the laminator PCB, I will certainly be making myself.