Saturday, 19 July 2014

KTM XCW GPS Lap Timer Build













I decided to build a lap timer for the KTM, so that I could record my lap times. There are a few on the market but no way I am spending £300 on one to use once in a blue moon.

The main feature in the end product is that you can set a start line position with GPS. When that start position is then passed, the lap restarts. This means you can ride say ten laps without having to touch the timer and then review the times afterwards. It has a 50 lap memory, with a max of 99 hours, 59 minutes and 59 seconds per lap.




I started off with a GPS module, a PIC micro controller and 16 digit LCD display. The prototype on breadboard  is above.



The software from the micro-controller was written in the C language using MPLAB, the pic was 16F1938 as this gave me the IO I needed as well as a USART to use with the GPS module.



The Maestro  module spits out a standard SIRF marine protocol for GPS devices. This means I just needed to extract the parts I needed and convert them to variables.


Commands received:
  • $GPGGA,200307.000,5217.7217,N,00153.2103,W,1,04,2.9,97.3,M,48.1,M,,0000*72
GGA Global Positioning System Fix Data. Time, Position and fix related data
for a GPS receiver
11
1 2 3 4 5 6 7 8 9 10 | 12 13 14 15
| | | | | | | | | | | | | | |
$--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh
1) Time (UTC)
2) Latitude
3) N or S (North or South)
4) Longitude
5) E or W (East or West)
6) GPS Quality Indicator,
0 - fix not available,
1 - GPS fix,
2 - Differential GPS fix
7) Number of satellites in view, 00 - 12
8) Horizontal Dilution of precision
9) Antenna Altitude above/below mean-sea-level (geoid)
10) Units of antenna altitude, meters
11) Geoidal separation, the difference between the WGS-84 earth
ellipsoid and mean-sea-level (geoid), "-" means mean-sea-level below ellipsoid
12) Units of geoidal separation, meters
13) Age of differential GPS data, time in seconds since last SC104
type 1 or 9 update, null field when DGPS is not used
14) Differential reference station ID, 0000-1023
15) Checksum

Non-fixed:
$GPGGA,134440.455,,,,,0,00,,,M,0.0,M,,0000*54

After fix:

$GPGGA,143428.000,5217.7175,N,00153.2144,W,1,04,4.1,83.2,M,48.1,M,,0000*72

The GPGGA packet gave me the time and position as well as if the module had a valid fix.

Once I had played around with the software and got the timer to work, which was easy with a one second pulse coming straight from the module. It was time to test it.

Walking around a field trying to get the thing to trigger was the first problem. It was difficult to set the start position tolerance, because you are never going to read the exact same position twice. So I opted to have a setting which you could change. This ended up being a tolerance of 0.003 on the co-ordinate position of 9999.9999 N 9999.9999W for example.

I then designed up a proper PCB and got it manufactured.

Schematic pages:



The IO between the GPS module and PIC had to be opto-isolataed because the PIC has a 5V supply and the GPS 3.3V.



PCB Layout:


The manufactured board from PCB train, this cost about £50 for two boards on a 15 day turn around.


I had to keep almost everything surface mount as I was short on space.
The populated PCB:


The PCB was designed so the LCD screen stacks on top with an inline standard pitch connector:


The final article installed on the bike, with the only waterproof enclosure I could find:


The green button next to the grip on the left is to cycle between the menus and start/stop the timer. I managed to find this on ebay as a replacement to another manufacturer's barpad lap timer so this suited perfectly.

The lap timer is now wired into the bike battery, not a PP3 as in the photo.

That's it, sorry it's not more in depth but there is over 50 hours of work here in software/hardware design.

I just need to find a better enclosure, something a bit sleeker looking.

No comments:

Post a Comment