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: https://github.com/JamesGlanville/uart_echo (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
3X AA batteries (lithium for improved power rating)
2X N-channel mosfets
3D printed catch
Backlit HD44780 16X2 LCD
6mm walnut wood panel
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 http://emerythacks.blogspot.co.uk/2013/01/u-blox-pci-5s-cheap-gps-module-for-your.html). 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).
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.
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.
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.