GPS Lap Timer; or Labotomised my Sat-Nav

Keep a log of a project build here. Be sure to include pictures and as much documentation as possible.

Re: GPS Lap Timer; or Labotomised my Sat-Nav

Postby nes » July 1st, 2012, 3:41 pm

Racing again this year, so time to revisit the lap timer.

Contradicting myself above, repeated rough treatment had caused it to become a bit unreliable and shut off unexpectedly occasionally. So the first mod was to mount the processor on a proper PCB.

20 minutes with Inkscape and a vernier calliper produced this ...
Image
... which after a further 40 minutes with a toner print, the clothes iron and some past-its-best ferric chloride turns into this:
Image
A postage stamp sized board with all the loose components soldered down neatly. Here we have: AVR, 3.3V regulator, two SM resistors for the USB data wires, some smoothing capacitors salvaged from a dead hard disk and an 8MHz crystal, the only component requiring holes to be drilled.
Image
Actually, picking apart the rat's nest of transformer wire and resoldering everything took another couple of hours, but it was worth doing it right.
Image

And here it is all repacked with a little less hot glue this time:
Image

Pictures of this year's car build can be found here.
User avatar
nes
 
Posts: 127
Joined: January 27th, 2011, 9:20 am

Re: GPS Lap Timer; or Labotomised my Sat-Nav

Postby nes » July 1st, 2012, 3:42 pm

I also had a chance to work on the software a little more. It's still hosted at Assembla, over here.

As well as actually saving the lap times in EEPROM, it now betters the one second precision you get with GPS positioning by reckoning the fraction of the second just elapsed that the start line was actually crossed. Sort of a bit like this:
Image

We know we've gone past the start point as we were getting closer but now we're starting to get further away from it again. The scheme is to plot a triangle between the two most recent GPS positions and the start point, then work out how far along the base the altitude intersects it and divide that by the length of the base. It's simplistic as we're assuming a straight course and a constant speed. It's probably better than not doing it at all though.
User avatar
nes
 
Posts: 127
Joined: January 27th, 2011, 9:20 am

Re: GPS Lap Timer; or Labotomised my Sat-Nav

Postby nes » July 8th, 2012, 6:07 am

Added a rudimentary way to export the race data from the box to a PC.

Starting with the keyboard device demo which ships with the rather excellent and open source LUFA USB library for Atmel devices, I hacked away until I got the lap timer effectively typing out the lap times into an editor running on the host.

The reasoning for doing it this way is that in theory it should work on any computer without needing drivers. The procedure is to plug the box in via USB, fire up any old editor on the PC (even Notepad), switch the lap timer on and it will automatically go into USB device mode. Then once the PC has finished doing its device enumeration (which is darn near instant with Linux) you press the button on the box and it types out a report of the saved data.

The text is nominally comma separated fields so the idea is you could save it and import it directly into a spreadsheet if you wanted.

As always, the changes are in the repo. If you want to build it you need the LUFA source project unzipped. Change the line in Makefile to point to the root of the LUFA source tree. e.g.:
Code: Select all
LUFA_PATH = ../../AVR/LUFA-120219
User avatar
nes
 
Posts: 127
Joined: January 27th, 2011, 9:20 am

Re: GPS Lap Timer; or Labotomised my Sat-Nav

Postby nes » July 8th, 2012, 6:13 am

While developing the USB client I managed to brick the shipped DFU boot loader somehow. As I had to connect a programmer to fix it, I decided to give the LUFA DFU clone a try. The project for it is included in the source tree, but you need to edit the makefile for the specific AVR you are using. I simply commented out any calls to board specific functions in the source (mostly for lighting up LEDs which I don't have).
Code: Select all
# MCU name
MCU = atmega32u2

# Target architecture (see library "Board Types" documentation).
ARCH = AVR8

# Target board (see library "Board Types" documentation, NONE for projects not requiring
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
# "Board" inside the application directory.
BOARD = NONE

and
Code: Select all
# Starting byte address of the bootloader, as a byte address - computed via the formula
#   BOOT_START = ((FLASH_SIZE_KB - BOOT_SECTION_SIZE_KB) * 1024)
#
# Note that the bootloader size and start address given in AVRStudio is in words and not
# bytes, and so will need to be doubled to obtain the byte address needed by AVR-GCC.
FLASH_SIZE_KB        = 32
BOOT_SECTION_SIZE_KB = 4


It fills just over 3.5k of the 4k allocated for the boot loader, so there is a little bit of space free to print messages on the LCD for example. I haven't bothered though. I can report it seems to work fine and if anything is a little more reliable than the boot loader Atmel ships. I have only used it with the free dfu-programmer utility rather than Atmel's own client/driver.
User avatar
nes
 
Posts: 127
Joined: January 27th, 2011, 9:20 am

Re: GPS Lap Timer; or Labotomised my Sat-Nav

Postby nes » July 13th, 2012, 4:56 pm

Tweaked the code a bit more to improve the formatting of the USB race reporting, and fix a few more bugs.

This is an example of what the box outputs when plugged into a USB host:
Code: Select all
Top speed, 26.80,km/h, at, 1815:46, lap, 1
Total distance,  2.591,km
Total run time,  9:26.0
Total rest time, 10:29.0

LAP  , SPLIT   , TIME
Start,         , 1812:17
    1,  3:29.00, 1815:46
    2,  3:42.26, 1819:28


Unfortunately, we only got a few laps in before disaster struck and the back axle sheared clean in half. :(
Image
That's 2.5mm wall 20mm diameter seamless mild steel tube. It's welded back together now. With luck it'll hold for the race this Sunday - it's gotta last 2 hours partly on cobbled streets.
User avatar
nes
 
Posts: 127
Joined: January 27th, 2011, 9:20 am

Re: GPS Lap Timer; or Labotomised my Sat-Nav

Postby nes » July 15th, 2012, 1:08 pm

Race over for the year. The car started falling apart after about 45 minutes of merciless pounding over cobbled streets but we provided some entertainment for the crowds at least.

Lap by lap report (the first lap was the parade lap followed by a long wait on the grid):
Code: Select all
Top speed, 30.40,km/h, at, 1144:08, lap, 27
Total distance,  26.961,km
Total run time,  93:02.0
Total rest time, 56:18.0

LAP  , SPLIT   , TIME
Start,         , 0942:39
    1, 33:07.36, 1015:47
    2,  2:32.01, 1018:19
    3,  2:26.20, 1020:45
    4,  2:04.47, 1022:49
    5,  2:41.28, 1025:31
    6,  2:40.76, 1028:11
    7,  2:37.21, 1030:49
    8,  2:01.44, 1032:50
    9,  2:26.47, 1035:17
   10,  2:34.25, 1037:51
   11,  2:25.06, 1040:16
   12,  2:19.86, 1042:36
   13,  2:45.15, 1045:21
   14,  2:36.44, 1047:57
   15,  8:31.17, 1056:28
   16, 10:05.92, 1106:34
   17,  2:53.33, 1109:28
   18,  3:02.65, 1112:30
   19,  4:02.50, 1116:33
   20,  2:55.85, 1119:29
   21,  3:54.45, 1123:23
   22,  4:11.76, 1127:35
   23,  2:57.02, 1130:32
   24,  2:57.04, 1133:29
   25,  3:13.60, 1136:43
   26,  6:28.39, 1143:11
   27,  3:23.46, 1146:35
   28,  7:20.21, 1153:55
   29,  4:16.87, 1158:12
   30,  2:21.15, 1200:33
   31,  2:48.28, 1203:21
   32,  2:36.10, 1205:57
   33,  2:55.21, 1208:52
   34,  3:28.21, 1212:21
User avatar
nes
 
Posts: 127
Joined: January 27th, 2011, 9:20 am

Re: GPS Lap Timer; or Labotomised my Sat-Nav

Postby davexxxxx1 » September 18th, 2013, 11:10 am

Can anyone help me to get this program run with Atmel Studio 6.1 on Windows?
davexxxxx1
 
Posts: 1
Joined: September 12th, 2013, 4:54 am

Previous

Return to Project Logs

Who is online

Users browsing this forum: No registered users and 4 guests