GPS Engagement ring box

As I am now happily engaged, I’m now able to share the plans for the engagement ring box that I made. The idea was to have the box give a distance in metres to a location every time a button was pushed, and only to open at that point. The box gave no directions, just the distance. When it got close enough (I arbitrarily chose 20m) the box opened to show the ring (as well as a jumble of electronics). I am not writing this as an instruction guide, more of a list of design choices I made and my thoughts about them now I have completed and used the project. All of the code is here: (I started with one of the launchpad’s example programs, and never got around to changing the project name)

Stellaris Launchpad development board
U-blox PCI-5S PCIe GPS card
GPS antenna
Push button
Reed switch
3X AA batteries (lithium for improved power rating)
2X N-channel mosfets
Micro Servo
3D printed catch
Backlit HD44780 16X2 LCD
2X Hinges
6mm walnut wood panel

GPS functionality
I decided to use the PCI-5S card as it was the cheapest I could find. Although it seems like a PCIe card would be difficult or impossible to interface to, in fact it has readily accessible UART points on the card that are easy to solder too (see I paired it with a cheap ceramic patch antenna and it performed well. To configure the module, you simply connect it via serial to a windows PC, and use u-center (U-blox free software) to program it. I simply raised the baud rate a little (as received the baud rate was too low, and some NMEA data was being truncated). To do this, I used the uart_echo program that was an example stellaris project since I did not have a 3.3V compatible usb-serial cable. The NMEA is parsed with a simple state machine that parses latitude and longitude from the NMEA stream on every serial interrupt (see code).

Box construction
I wanted the box to look nice, so I decided to hand make it from some nice wood. I found a 100x457x6mm sheet of walnut on ebay relatively cheaply, and used almost all of it. I made it by cutting the four sides, adding dovetail joints to the sides with a cheap scalpel and gluing those together. When that was dry, I traced the inside twice onto more walnut for the lid and base. When these were cut and glued in place (to form a closed box), I sawed the box very carefully in two, being sure to cut through the centre of the dovetails. Hinges were then glued in place (there was not enough space for screws) inside the cutouts I had previously made.

I chose to cut the dovetails pins-first. There are a lot of extremely good youtube tutorials for this, so I won’t go in to much detail. The main thing to be careful with is that you should make the joint parts slightly (say 0.5mm-1mm) too long. This enables you to sand the finished joint flat without having to sand the entire panel away.

Power supply and use
As the box only needed to be on for a few hours at most, I decided to have the launchpad running constantly. The LDO regulator onboard normally goes 5.0V -> 3.3V. However, it was capable of operating from just the 4.5V of 3 AA batteries in series. I decided to use some energizer lithiums to ensure sufficient battery life, although I do not think this was really necessary. I needed to reduce standby current draw as much as possible, so the launchpad hibernates as often as possible, powering on only after the button is pressed. For the sake of speed, the GPS module was always connected to power, although that only needed 100mA. The servo and the LCD (due to the backlight) draw significant standby power, so I decided to switch the power to them on and off. I only had n-channel mosfets so decided to use them, even though using a p-channel high-side switch would have been much simpler. The LCD is driven by 3.3V, so it was enough to just push all the data inputs to 3.3V, then switch the mosfet off. In this manner, all LCD pins were at 3.3V, so there was no relative potential between any of them. The servo is driven by the batteries’ ~4.5V. I used the nasty hack of hoping the servo could deal with the -1.2V applied to it’s input pin compared to its power and ground pins. I used a large series resistor, and it worked, though if I did it again I would just use a p-channel mosfet to be safer.

Box lock
I decided to use a micro servo for the lock mechanism because they’re cheap (<£3 each if you buy a few from ebay), and fairly powerful. They also don’t need any significant driving circuitry. I just 3D printed (because it was easy, and I am lazy) a small catch to glue to the top of the box, and screwed on one of the supplied servo horns. This worked well, and had the nice side effect of making a cool geary growl when the box opened.

Emergency override
In case the box failed to open, I decided to add a small reed switch to the top of the box. When triggered, this triggered an interrupt which opened the lock, regardless of the current location or state. This actually came in incredibly useful when the GPS lock proved to be slightly off, despite the fact the destination had been reached. 

Choice of microcontroller
I had the stellaris launchpad lying around (I got a few free, and a few very cheaply) so decided to use that. I find the software very easy to use (the IDE is based on eclipse) and the debugger is quite powerful. It was also useful to have a development board that could source a few hundred milliamps at 3.3V output so I did not have to add my own regulator for the GPS module. However, there is not a huge amount of computation that needs to be done in this application, so a small AVR would have sufficed. All the code is in my github repository listed at the top of this page.


Converting a Proxxon MF-70 Mill to CNC

I recently converted my mf-70 to cnc control, and I’ve decided to write about it because it’s surprisingly easy, and makes an awesome tool. Seen above is the completed mill, next to a SOIC-20 breakout board I milled with it.

I’m going to divide this post into:

1) Mechanics: Basically just coupling stepper motors to the axes. Also, replacing the spindle motor with a brushless motor (optional).

2) Electronics: usb->rs232->gcode->stepper commands (Basically reprap electronics).

3) Software: PCB layout -> gcode.


1) I decided to use NEMA23 steppers to control the 3 axes, since I had some lying around. They have a LOT of torque, and are small enough to fit easily. Initially, I used some 3d printed couplers ( to attach the motors to the threaded rods. They had a fair bit of slop, but the real aim was to manage to cnc mill some proper oldham couplers:

Oldham couplings have the really nice property that they tolerate axial misalignment quite happily – in my case I’m using 32mm steel rod for the coupling, and they tolerate 5-10mm misalignment well.  Milling instructions are in the previous post on this blog.

Annoyingly, I managed to burn out my spindle motor within hours of use (I was milling steel at much too fast a feedrate so the motor stalled). I was initially panicked, but then realised I had a spare brushless motor than might just do the job. I ended up using a TURNIGY plush 25Amp ESC with a TURNIGY 2217 860kv 22A outrunner, and coupling to the spindle with a small 3d printed part I made ( The motor was loosely secured with cable ties. I needed some control that would output servo commands to control the ESC, so I used the schematic at: 556 Based Servo Exerciser . The fan sitting on top is to cool down the motor (the motors can overheat, since they’re really made to be coupled to a propeller in an rc model).

2) I had a bunch of spare parts lying around from previous 3d printer projects, so I mushed some together to get some free electronics:

1x sanguino board
2x stepper motor driver v1.2 (
1x  DRV20/S (

I use marlin firmware (, and the stepper drivers are easy to attach (step/dir/enable). You can use any stepper drivers and electronics that work with Marlin/grbl/whatever. The drivers get pretty hot, so they’re housed in a wooden box with fans at each end.

3) I use eagle with pcb2gcode to generate the gcode. You just need to generate the board layout with eagle, then use the CAM processor with (

Then, you just need a pcb2gcode millproject file (for arcane reasons, pcb2gcode expects a file called milproject in the current directory). I use:

# this is an example config file for pcb2gcode. 
# place this in the same directory as your gerber files to save typing metric=1 # You may want to uncomment and change those in local project file 

# parameters for isolation routing / engraving / etching zwork=10 zsafe=12

# drilling parameters

# generate voronoi regions

You’ll need the metric version of pcb2gcode at:

Then you just need to modify millproject to contain the exact file that you want to be milled, then you can just run ./pcb2gcode in the directory containing millproject and your gerber files, which will give you a .ngc file. You can then push this to the mill with something like pronterface (

In order to get everything lined up correctly, I use the following steps:

I tell the FW that the axes locations are at some arbitrary large number (G92 X100; G92 Y100; G92 Z100)

I use pronterface to jog the axes until x and y are where I want 0,0 to be.

I tell the FW that it is at 0,0 (G92 X0; G92 Y0)

I move the Z axes down until the tip is touching the copper (I will in future automate this with a probe).

I then tell the FW that the Z axis is at 10mm + cut depth (say for example G92 Z10.2)

I hit start.

Making oldham couplings

As part of my mf-70 cnc mill conversion (upcoming post), I needed to couple the nema23 motors to the axis leadscrews. I decided to make some oldham couplings. They’re quite simple, two metal discs that are clamped to the axes, with a groove in each. A piece of acrylic between can slide, so no translational forces can be transferred.

32mm steel bar
10mm acrylic sheet

M6 tap
various drills/endmills
m6 bolts

Start by cutting the steel into two short lengths (I used about 12mm, doesn’t matter too much). Drill a hole all the way through lengthwise, to match the shaft diameters (I think I used 7mm and 5mm). Next, drill a 5MM hole through the side, about 3/4 of the way through. Tap this to M6, and insert a holding bolt. Next mill off about 8mm of each side, to about 3mm deep. The steel parts are done now, so sand any rough edges.

Next, mill the acrylic center. I used cambam to produce the gcode. You have to flip the disk to mill the other side, try to get the other cut at exactly 90 degrees. You can even just use polymorph (low temperature melting plastic), just heat it, push the metal disks in at 90 degrees and let set.

Just push the pieces together into a stack, and the axes will run smoothly (might want to add a drop of oil). The advantage of this type of coupling is you don’t need to align the shafts much at all, which makes a bodged solution like you see in the picture possible.


So I finished my clock today. I was thinking I’d have to wait for the clock module to arrive from the far east, but an amazing bloke from the cambridge makespace gave me a DS1307 this evening, and it didn’t take long after that to get done. The TLDR first:

Cost me only about £10.
Code is here for the stellaris launchpad:
3d printed case for now until I can mill a wooden one.
VFD clocks are really fun to make.

Anyway, on to more verbose musings. Firstly I needed to get the DS1307 wired up. I did not have a 32.768khz crystal lying around that I could find, but the launchpad has one onboard that I was not using (I was using the higher frequency one). I very, very carefully heated the solder joints while pulling up the crystal wires, then soldered the DS1307 deadbug style onto the launchpad and wired everything up:

It was pretty simple to wire up, pins 1 and 2 to the crystal (the body of which was soldered to the board so I had no choice where to place the DS1307 and keep short wires to the crystal). Pin 3 to the battery backup (more on this in a sec). 4 to ground, 5 to SDA, 6 to SCL, 7 to SQW, and 8 to +5V. The two 4.7k resistors pull up SDA and SCL to 3.3V. Luckily, although the DS1307 is 5V powered only, it works with 3.3V i2c comms, which saved me the hassle of using a level converter. For the battery, I was using a CR2016 since I had one lying around and it was 3V which I needed. I didn’t have a battery case, so I very carefully soldered wires to the battery, hot glued them for protection, then duct tape the lot into a little bundle:

Now soldering to lithium button cells is not really advisable, but if you want to do it reasonably safely, do this: Sand down a spot on each side to make contact to, and score the area lightly with a knife too for good measure. Take the wires, melt a reasonably big blob of solder onto the end of each, and let cool. Then, place the blob on the sanded area holding the wire. With the hottest soldering iron/setting you have, push down onto the blob for as little time as is possible to make a joint. Then, fan/blow on the battery. I had no problems doing this, and it saved a lot of space vs using a socket.

I 3d printed a case I designed quickly. Ultimately I think I’ll mill/lasercut a prettier case out of wood, but having a 3d printer on my desk (mendelmax 1.5) was by far the quickest option. The stl and scad files are in the git repository FOR REFERENCE ONLY! I made a stupid mistake and put the cutout for the usb cable on the wrong side, and the body was a 4 hour print so I just sawed the case a bit, and added a bit extra to the base to fill up the gap. It works, and you can’t really see the join, but it’s not ideal:

I found the clock skidded around a bit on my desk, so I cut up an old bike inner tube, and superglued it flat on the base. This looks ugly from below, but works excellently and you can’t see it in normal operation:

That’s all there is I think, it was a fun project, and a useful and different little clock to go on my desk. I still have 18 IV-3 tubes with no purpose, and 2 MAX6921, so I suspect I’ll get a third VFD clock at some point. I’ve tried to comment my code as well as I can, since the launchpad is an interesting little board, but the documentation is not great, and hopefully it’ll be a useful example of a few things.

Getting rid of the voltage supervisor (for the wrong reasons)

One thing I neglected to mention is that I followed the instructions here: to stop the launchpad resetting when the 5v supply dropped. This was because when I was experimenting with a large duty cycle for the SMPS the current draw from the inductor was enough to wobble the 5V rail enough to reset the chip. I don’t think I actually needed to do this – it shouldn’t reset now I’ve lowered the duty cycle.

Another thing is that I decided to drop to just 2 47 ohm resisistors in series for each tube as they really were too dim. I strongly suspect I’m now drawing more than the supposed 500mA maximum for a USB device, but only by a little bit, and I’ll be powering it with an old iphone charger that can handle it.

Wrestling with interrupts

I’ve put all my code so far on github ( Part of the reason for choosing to use the launchpad was to experiment with it – my thoughts are that it is a very nice board, but the documentation is very poor. I’ve therefore commented my code, and tried to make it as clear as possible, because there are a few things (i2c, PWM, interrupts) that are very common, and took quite a lot of searching to get right. The current state of the code is that is does everything except get the initial time from the DS1307 via i2c because I don’t have the chip yet. However, the interrupt to process the 1Hz signal the ds1307 gives is working. (The plan is to get the initial time, then count the ticks since then to get the current time.)

Mini switch mode power supply

So I got the inductors in the post today, and had to work out how to fit all the boost circuitry into as little space as possible. I decided to make a little cylinder of parts, and heatshrink the lot, then I could cram it next to the multiplexing layer on the pcb. It was pretty easy to make, and I’ll be making a few more of these for various uses. The four wires are 5V, 0V, switching signal, and high voltage output. I’m using open loop control, and I get a stable 50V output – it’s weird that you can feel a tingle if you touch it, and it’s only powered by usb. The parts used were:

2.2mH inductor
Mosfet – CSD18532KCS, but practically any will do if they can handle 60V and can be driven from a logic level.
1 high voltage capacitor – I used a 300uF 300V capacitor, you need one >60V and >50uF.
1 low voltage capacitor – I used a 220uF 16V capacitor
diode – I just used a random IN4001 one I had lying around

The circuit is the same as the ice tube clock (

So here is what I have so far (you can just about see the end of the high voltage capacitor in the background. It’s powered only by usb, and displays 18:11:11 at all times. Now I just need to add the ds1307 when it arrives and write a little code.

Clock #2

So I finished my first VFD clock, and wanted another. I found a great deal on some single-digit IV-3 tubes on ebay (24 for less than £10), so I decided to make a similar clock but with these tubes. Once again, I wanted to spend as little money as possible, so here were the parts I was going to use:

6 IV-3 tubes (£2.50 total)
MAX6921 VFD driver (free sample)
CSD18533KCS MOSFET for SMPS (free sample)
DS1307 clock module ( (£1.50, probably just as cheap as battery+ds1307+battery holder)
2.2mH inductor ( 80p)
Stellaris launchpad LM4F120 (£5)
Various bits of wire/perfboard/passive components (junk drawer – free.)

All in all, about £10, which seems quite reasonable.

Right now I can set all the digits with the firmware I wrote for the launchpad. I’m waiting for the inductor in the post, so right now i’m using the high voltage power from my previous vfd clock. I’m also waiting for the ds1307 module, so it can’t keep time, but I feel like I’m mostly there. I can’t imagine anyone will copy my design exactly, but here are a few thoughts/pointers/why I’m building this the way I am:

I needed to multiplex the tubes so I could control them easily. This is really simple to do, you just connect all the wires that correspond to a segment together, and connect all the 0V filament wires for the tubes. Then you just selectively power on one grid, and display whatever you want by controlling the segment wires. This reduces the number of wires to: 8 segment wires (counting the full stop), 6 grids, ground, and 6 +ve filament wires. The filaments need a small amount of current flowing through them – I’m using about 30mA. This is estimated from an old russian datasheet I found. I’m powering them each through 141 ohms from 5V (I only had 47ohm high-wattage resistors in that range, so the duct-taped blob labelled in the picture is an array of 47ohm resistors in series.) Now there are just 8 segment wires, 6 grids, ground and 5V – much more manageable.

I’m using the MAX6921 vfd driver again, because it’s really easy to use. I wanted to start building this late at night without any etchant or fine enough milling bits, so I decided to go for the tried and tested method of supergluing the chip onto perfboard on its back, then adding a load of fiddly interconnects to turn the chip into a manageable size. I only needed 20 pins (14 to vfd, 5v, +40V, ground, DIN, LOAD,CLK), so I didn’t bother connecting all of the pins of the max6921. This picture shows the idea: (the top pcb has the max6921 glued to the back, and the solder blobs along the edges correspond to various pins on the 6921)

At this point, I had a module that just needed a 5v supply, a high voltage for the tubes (~40V), and some communication over the DIN, LOAD and CLK pins. Time for the brain of the clock. I decided to use the stellaris launchpad because I bought a couple cheaply ages ago and they can be powered by microusb, have a load of processing power, and their 3.3V running voltage is just about big enough to run the max6921. Not only can they be powered by usb, they have usb comms, so I can set the time by just plugging the clock into my pc. This I’ll do by just flashing a firmware with a hardcoded time, the same thing I do with my iv-18 clock – it’s a straightforward thing I only need to do twice a year for DST, then let the DS1307 keep time. The code is just a modified version of the project0 project that comes with the stellaris software. I haven’t used one of these things before, but I quite like the launchpad already. My code is here: project0. I’ll put all of it in a git repo when I’m done.

So, a TODO list:

Wire up the SMPS, and set up PID control using pwm and a potential divider to measure the voltage – easy wiring, should be simple code.

Wire up the DS1307 module, and write the code to set/check the time.

Build a case. I can’t decide whether to 3d print one (dead easy) or craft one out of wood (better looking, much more lengthy process)

Finished :)

I’ve finished the clock now, I mounted it to a wooden base with copper loops, secured from underneath with hot glue. I opted in the end for a DS1307 powered clock, hence the little button battery held cunningly to the bottom left. I couldn’t decide the best way to write the firmware, as reading the ds1307 takes a little too long, so it disturbs the persistence of vision effect. It therefore updates the time every minute or so, which looks a lot better.

Code is here:

The code is a bit rubbish, as the wires on the VFD are attached semi-randomly to pins on the MAX6921, so there’s a nasty bit of magic code to work out which segments are which.


The digits are really clear in real life, it is just hard to photograph.

SMPS boost converter complete

I finally got around to rewinding an old inductor, to get a 1.7mH inductor. I used the same schematic as the mintyboost more or less, though I used a STP55NF06 mosfet (had one lying around). I also had to pull down the switching signal from the MCU with a 4.7k resistor. Without it, the inductor heated up massively, and I couldn’t figure out why the MCU wasn’t pulling the pin down to ground properly. Ah well, it works. In hindsight, that was probably the reason the original 0.2mH inductor wasn’t working, but ah well, winding hundreds of turns of copper around a tiny bobbin is fun.

I’ll probably add a ds1307 for timekeeping, since I found one in my parts box. There’s a nice empty bit of space on the bottom right of the clock for it.

Using capacitors as spacers for the power rails has been really useful – the two copper wires running horizontal behind and above the tube are suspended at either end from small electrolytic capacitors. I went for a 600uF cap for the 40V rail, much bigger than necessary, but it does make the clock “warm up” slowly, and power off gently, whereas with a smaller one it was much more abrupt.