As you will hopefully recall from my previous blog, when I purchased a 1953 International pickup truck, I decided to add a digital speedometer. I elected to use Nixie tubes because they have an appropriate vintage feel and bring a warm, fuzzy feeling to the party. Furthermore, I decided to use a GPS unit that would let me determine my speed without hacking into my speed cable or cobble Hall effect sensors and the like together.
My version of the project ended up using the parts shown below. You can substitute other parts as you wish, but I ended up with these either out of convenience or because I happened to have them lying around in my treasure chest.
- One high-voltage DC 115-235V Nixie tube driver ($18 on eBay)
- Two K155ID1 Nixie tube drivers ($2 each on eBay)
- Two Nixie tubes ($10 each on eBay)
- One PmodGPS GPS receiver ($45)
- One Basys2 Spartan-3E FPGA board ($50)
As I noted before, you can find cheaper GPS receiver modules and make your own DC-DC converter, but if you already have something at hand, you might as well use it. This project works with high voltages, so please be careful.
Decoding the GPS
The Pmod GPS plugs right into the BASYS2 connector. This module was not easy to integrate, and the documentation is lacking. All I needed was the speed-over-ground message. Before I get too far, the physical interface is 3.3V signaling, 9600baud, start bit, stop bit. The GPS blinks a LED once a second until it locks on the satellites. However, I discovered that serial data was always flowing from the module, even without a lock.
Five ASCII messages come out of the module every second, each one commencing with a $ character. To obtain the speed value, I needed to decode a data stream that looks like this.
In this example, the speed is 0.06 kilometers per hour. This example is not as helpful as it could be. What about when the speed is 10 or 100kph? By trial and error, I discovered that the message is variable. For 10 and 100kph, it will look something like this (it would have been nice if someone had told me):
The trick to finding the speed from the five messages is to look for the sequence $GPVTN,SPEED. To help me debug the data stream, I inserted a 4k FIFO that stores the GPS data and is displayed every second or so to the rightmost pair of seven-segment LED digits on my FPGA board. This was very helpful. Remember that the message is in ASCII; we have to subtract hexadecimal 30 from each numerical digit to obtain the decimal equivalent. Also, look for that decimal point delimiter, because the speed could have one, two, or three digits. This snippet of VHDL shows some of the decoding.
KPH to MPH
After the speed is located and decoded from the GPS message, the next step is to convert it from kilometers to miles per hour. I decided to use a lookup table, as illustrated below.
I also have a smaller version of this design that fits into a CPLD — I’m too cheap to stuff this FPGA board into my truck. For the purposes of this exercise, though, I used a lookup table. This output is by nature in BCD format, so it mates up nicely with the K155ID1 Nixie tube drivers. It’s simple and fast. Since I wish to display my speed only in miles per hour, and since my truck will never go faster than 99mph, two Nixie tube digits will suffice. If you wish to display your speed in kilometers per hour, you will need three Nixie tubes. The accuracy of the speedo is about +/- 1mph, and the update rate is one second. GPS is sensitive to drift, bridges, etc., but this setup works well as an overall speedometer.
To Page 2 >