Homebrew PCBs first attempt

Here is the first PCB that came out alright:

Homemade PCB

Homemade PCB

There were several fails before this. This post will document some of the things I have learned so far. First off, in my limited experience, tracing paper is much better than transparencies for printing the artwork on to. I’m using a 1200×1200 dpi laser printer and when using the transparencies the artwork consistently came out of the printer blurred. I tried changing around some settings on the printer but the blurred images persisted. Then I tried tracing paper and it really is brilliant stuff. It looks like the ink can adhere to the tracing paper much easier than the transparencies so the images are much more sharply defined:

Artwork on tracing paper

Artwork on tracing paper

Blurred artwork on transparency

Blurred artwork on transparency

The next step was finding out how long the UV exposure box takes to fully expose a PCB. Under exposure will result in short circuits and over exposure will result in broken traces so finding the right amount of time is important. I found the right exposure time by trial and error. I knew it was probably somewhere between 2-8 minutes based on other UV boxes I’ve seen online. The way I found the perfect amount of time was by printing out some tqfp-44 packages onto tracing paper like so:

5 TQFP packages on tracing paper

5 TQFP packages on tracing paper

I’m using pre-sensitized fr4 boards at the moment. So I cut off a piece of the fr4 big enough for the 5 tqfp packages. I then exposed the whole thing to UV for 2 minutes and then every 30 seconds after that I blocked off one tqfp package from the UV using a piece of cardboard. That means for every tqfp footprint was 30 seconds of extra exposure. The first run I started from 2 minutes, then 30 seconds later blocked off one tqfp part and so on for 2 and a half minutes. This gave me exposure time from 2-4.5 minutes. This is the result:

Varied exposure times

Varied exposure times

The above image isn’t very clear but basically the rightmost tqfp footprint was exposed for 2mins, the next one for 2.5 mins and so on all the way up to 4.5 mins on the very left. I didn’t bother fully etching this board because it was obvious that around 4-4.5 mins was the minimum. I then repeated the experiment starting from 4.5 mins up to 7 mins. Here is the results of 4.5 – 7 mins. The best one is 4.5 and the most faded is 7 mins.

UV exposure varied from 4.5 - 7 mins

UV exposure varied from 4.5 – 7 mins

Looking at the left most footprint in the above image some of the pads were slightly over exposed. So I went with 4 minutes for exposure instead of 4.5. I then printed a test circuit seen on the stop of this page. Its just the top layer of a two layer board:

It’s got a ssop-16 package and a ssp-20 package which both have fairly small pin pitch and it etched out just fine. I used this guide on making PCBs made by Mike from mikeselectricstuff . It is an extremely useful guide and his methods give great results.

DIY UV PCB exposure box

UV exposure boxes sell for hundreds of euros from vendors such as RS electronics and Farnell when they can be built at home for approximately 70 euro. I used a plant pot to build mine because it was the only opaque container I could easily get my hands on.
2014-08-21 16.40.54

Here is a picture of the parts needed. Note that there should be two ballasts and not one.
Things needed for the build

Looking at the below picture of a close up of one of the ballasts you will notice that the circuit diagram printed on it shows that it can power two lamps (2x15W) in series. I tried doing it this way but could not get the lamps to start. So I bought a second ballast and wired a ballast to each lamp and it worked fine. This could just be due to the brand of ballast or the types of lamps I have.

Magnetic Ballast

Magnetic Ballast

This wiring diagram from wikimedia is very useful. This wiring layout is used for both lamps.

For the housing, a mirror on the base will help even the light distribution and increased the amount of light from the lamps that actually reaches the pcb. Also on top of the box you will want piece of glass or clear acrylic to sit the pcb on. I got a piece of mirror and glass cut for 10 euro from a local glass cutting company. Here is a picture of the mirror sitting in the plant pot:
2014-08-21 16.42.11

Next I added in the screwed the ballasts on the inside of the pot and made a hole for the mains connector which was just a three pin mains socket. From there just followed the wiring diagram above and ended up with this:

UV exposure box with electronics visible

UV exposure box with electronics visible

Plug in the mains after checking wiring to make sure everything works as expected:
2014-08-26 12.41.04

Hiding the electronics is the next step. This is for two reasons. The first being that the electronics look fairly unsightly (Not that I’m going for aesthetics here or anything). Secondly, it is better if the section of glass left visible is lined up with the center of the two lamps. So when you put down a board it is easy to line it up in the middle of both lamps for even light distribution. I used electrical tape to cover up part of the glass like so:
2014-08-26 12.52.24

I didn’t put a lid on the box because it really doesn’t seem necessary. I think just placing the board on the glass then maybe putting a piece of wood on top should do the job just fine. I didn’t add a timer either, I’m just going to use a smartphone timer app and manually turn off the power. Also, there is not switch because the power socket I use for this has a switch, or the cable could just be unplugged.

Bill of materials

Price (Euros)
2Magnetic Ballast 30WRS electronics. Order No: 793468218
2T8 Fluorescent Lamp 10WEbay http://goo.gl/KAbd4J20
44 T8 Lamp holders/clipsElectrical wholesalers2
2 Fluorescent StartersElectrical wholesalers2
2Fluorescent starter holdersElectrical wholesalers2
1Mains power 3 pin socketElectrical wholesalers1.50
1Single core wire (3 metres)Electrical wholesalers2.50
1Piece of mirror (30cm x 20xm)Glass supplier and cutter5
1Piece of glass/acrylic (40cmx25cm)Glass supplier and cutter5
1Box/Container/Plant potHardware Shop10
Total : 68

Mains power detection circuit

Circuit Diagram

Circuit Diagram

RLC circuit

RLC circuit

RLC circuit

Breadboard circuit

Code used for microcontroller:

The uC used was a pic18f14k50. Code compiled using xc8 compilter. Read analog channel function taken from batchloaf’s template code post. Here is the source code:

#include <xc.h>
#include <stdio.h>
#include <delays.h>


void setup(void);
unsigned int read_analog_channel (void);


int voltage;

void main(void)
		if(read_analog_channel() > 310) LATCbits.LATC4 = 1;
		else LATCbits.LATC4 = 0;
void setup(void)
    OSCCON = 0b01100011; //internal oscillator block, 8MHz clock speed.
    TRISC = 0b00000001; 
    TRISB = 0b00000000;
    LATB = 0b00000000;
    LATC = 0b00000000;
    ADCON2 = 0b00000011;// a/d conversion clock (dedicated clock)
    ANSELbits.ANS4 = 1; // front right ir 
    ADCON0 = 0b00010000; // chose an4 analog channel

unsigned int read_analog_channel (void)
    voltage = 0;
    ADCON0bits.ADON = 1;
    Delay1TCY();// 8us Delay for capacitor charge
    ADCON0bits.GO = 1;
    while(ADCON0bits.GO); // wait for conversion to complete
    voltage = ADRESH;
    voltage = (voltage<<2) + (ADRESL>>6);
    return voltage;

Making an updating graph using javascript and jpgraph

The graph will update in :

This is a pretty cool way to update a graph on a webpage without having to refresh the entire page. Javascript is an easy language to get started in, today was my first time using it and within a few hours it was doing what I wanted. This stack overflow question was useful for my needs. I used the code from the first answer and just added in some simple code to refresh the image when the counter reaches 0. I also want to find out how to make the counter wait for the image to load before it continues counting because sometimes there is a lag between the counter hitting zero and the graph updating, so thats the next thing to try out. For now I just want to document what I have got working so far.

The PHP code that produces the graph:

The PHP script used to produce this graph is very similar to my previous post about using jpgraph with MySQL. This time though, the numbers being plotted aren’t coming from a database, they are just random numbers generated using the rand function in PHP.

Here is the PHP script:

<?php // content="text/plain; charset=utf-8"

define('__ROOT__', dirname(dirname(__FILE__))); 
require_once ('../jpgraph.php');
require_once ('../jpgraph_line.php');
require_once ('../jpgraph_error.php');

$y_axis = array();

for($i=0; $i<40; $i++) {
		$y_axis[] = rand(0,100);

$graph = new Graph(800,500);
$graph->title->Set("Example of line centered plot");

$p1 = new LinePlot($y_axis);



This PHP script outputs an image of a graph. The way this image is included in a webpage using html would be by using the img tag with the src attribute pointing to the PHP script like this:

<img id="myImage" src="http://www.wattnotions.com/jpgraph/src/mygraphs/rand_graph.php" />

Using javascript to refresh the image from the same URL

One cool thing about javascript is how easy it is to mess about with and change the properties of HTML tags. One small note about loading an image from the same URl is that some unique identifier should be appended to the end to force the browser to load the image from source as opposed to using the cache. This is achieved in the example below by putting a ‘?’ at the end of the URL and then adding the date and time. This ensures that every time a new image is loaded it will have a unique URL.

var image = document.getElementById('myImage');
image.src = "http://wattnotions.com/jpgraph/src/mygraphs/rand_graph.php?" + new Date().getTime();

Here is the javascript used to produce the timer and update the graph:

and thats it! This will be useful for viewing something like sensor data is close to real time. For example if there was an internet connected temperature sensor with the temperature data being placed in a MySQL database a PHP script to get the last 10 minutes worth of entries and then update the graph would be fairly simple to do.