Sunday, November 2, 2008

Rugby Scoring System

I recently embarked upon a project to build a rugby scoring system. In the many years of being a ground marshal at village rugby games I got sick and tired of being asked the score or the remaining minutes in the half/game. The closer the game, the more often people come to the scoring tent to ask.

It was with this in mind that I had a look on the Internet for a scoring system. I had scored at Andrew’s basketball games so I was familiar with how easy the system can be made to operate. Unfortunately I could not find anything that was a reasonable price for my low-end requirement. Sure there are ones for 10’s of thousands but nothing for a couple of hundred. Being an old ham and an electronics hobbyist as a child I thought what a good opportunity to re-kindle this hobby and what better than a project to help the rugby club?

First I needed a display. There aren’t many out there and I didn’t want to build one from scratch (with LEDs, muxes and transistors). I found this one for $170 at Jaycar:




It is 8 characters wide and 50mm high and it works a treat. With some boxing and a shade of some sort it will be plenty bright enough for a clear winter’s day. It can scroll through several messages so I will have a sequence something like:

HOME 33

AWAY 24

TIME 10m


Problem #1: The display is operated by a program on a PC or using a TV-like remote control. This is not much use when I want to drive it from a program on a small microcontroller. In comes the old programming skill to reverse engineer the serial protocol that drives this thing. I downloaded four different serial sniffer programs before I got one that did what I needed. The best one was called Comm Port Toolkit. It allowed me to scan the serial connection and insert my own strings to test my theories as I developed them. It has a 30 day free trial period without limitations which should be ample time for me to reverse engineer the protocol and test it. In fact, I’ve pretty much nailed most of the operations I need to perform on it already.

Then I needed a microcontroller that had the following:

1. Serial port to drive the display sign

2. LCD interface for the operator

3. Real-time clock for timing the game

4. Sufficient i/o to handle home and away, plus/minus try, penalty and conversion buttons as well as some control/setup buttons

I chose this board because there looks to be good tool support for it and it used very little power and had a battery backed up RTC: LPC 2103.











I got a compatible LCD display like this one for the operator:









The LPC2103 came with an older version of Keil uVision CARM which I installed and familiarised myself with. Being an old C/C++ programmer the C was pretty easy to master but I must admit I am rusty.

Problem #2: Programming the LPC2103’s flash from my Vista laptop via a USB to serial connection (because my laptop doesn’t have quaint stuff like a DB9 serial connection and the uVision doesn’t run on Ubuntu) didn’t work.

The Phillips flash programmer that came with the board just would not work so I downloaded one from here called FlashMagic which works great. Since I am not using it for production or commercial use then I can use it for free!

After a couple of hours I had downloaded into my LPC2103 a few of the test programs and was able to see them operate. One was to control the LCD and another to echo characters from the serial port.

Problem #3: In the old days of ASCII/ANSI terminals I would just fire up Windows Terminal on my PC and view the serial interaction. I had my sniffer working so I could see what was being written to the port but had no way to respond. Seems they dropped Windows Terminal from Vista. No worries, I found that my Ubuntu distribution comes with Minicom which is a simple terminal emulator. I configured that in short order with a bit of trial and error to figure out which ttySx is the serial port Com2. If anyone is reading this and can tell me how to determine the tty# of a port on the back of a clone PC I’d like to know. I simply tried a few until it worked. My assumption is that ttyS0 is COM1 and ttyS1 is COM2 and so forth.

So by this stage I have been able to do the following:

· Write a program and download it into the microcontroller

· Drive an LCD

· Drive a serial port

· Figured out most of the LED display sign’s protocol

I then combined two of the example programs – UART1 and LCD – into one which tested my rusty C skills. I really thought I would never use things like “extern” again. It took me an hour or so to remember/re-figure-out the compiling and linking rules. It’s amazing how you unlock one small item of information in your memory and it opens a whole room of memories from my programming days.

This week my goal is to:

1. Sense switch actuation in the program using the general purpose i/o ports.

2. Drive the LED display sign from UART1 (serial port) from the LPC2103

3. Set and read the real time clock

Melsy tolerated yet another visit to Jaycar in Blacktown on Saturday to pick up some more bits and pieces (including a xmas present to Alyssa to smooth things a little). I got a case with a sloping front which will be the operator’s panel, some mod wire, ribbon cable and once only push button switches. The only other item that I will need with be a power source. I am hoping to buy a small lead acid battery to drive everything. It will need to last a full day of rugby (7am to 4pm). When I get closer to the end I will figure out the current this setup draws and get an appropriate sized battery.

I go to sleep wondering about switch bounce on GPIO lines. How much fun is this?

No comments: