Motion Tracking Turret

This is the remaining documentation for my 2010 A2 level project I could scavenge together. The course was probably the most interesting part of my education to date, and also the most successful, as I finished with a mark of 596/600, putting me as one of the top 5 students in the country (but they won't tell me exactly where I came).

The initial design specification aimed for a paintball turret that could hit a person at up to 15 meters. The idea was at this distance the gun itself should be nearly perfectly accurate, meaning all inaccuracies would be introduced by the turret mechanism itself. Sadly this specification was a little ambitious for many reasons, such as the servos needed to move a 5kg paintball gun being very expensive, and the fact that bringing a paintball gun into a school is a little sketchy to say the least.

Despite this painful slap back to reality, I progressed with the project anyway, this time aiming just a laser pointer. The first step was to construct the turret hardware, shown in the picture above. The device was relatively small, standing around 150mm high, but this low mass allowed it to be an agile beast. The actuators were two small nameless RC servos, mounted in a plastic frame produced by a laser cutter. A laser pointer was then mounted to the second servo arm, thus completing the hardware construction.

To control the servos from the processing computer, an intermediate stage was required to convert the commands from a serial port into the required 50Hz PWM signal. I could have possibly skipped this stage by tapping into the computers audio output, but I was advised using a microcontroller would definitely give me some extra credit.

Initial testing was done on a PICAXE 18X chip, similar to the one used in my AS level chronograph. This chip is basically just a PIC16F88, with a BASIC stamp. This sounds good in theory, but in practise I found the UART module to be incredibly unreliable, meaning I had to bit bang the serial data, which also turned out to be equally unreliable. This may have been down to a poorly calibrated clock, or the basic stamp messing up timings. Either way, I felt it was time to move onto a different chip.

This is where I first fell in love with Microchips range of microcontrollers. I decided on a PIC16F887 development board, finding the UART module in this chip infinitely more reliable. It was then programmed to accept decimal numbers from the PC, then convert them into the required PWM duty cycle and frequency. The interface was relatively simple, thanks to the use of a MAX232 serial level converter, a chip I couldn't live without these days.

The hardest part was then designing the motion detection software. As a 17 year old with only intermediate programming experience, I felt trying to design my own motion detection algorithms and camera interface was a little ambitious, so I borrowed a lot of code from this open source project. All I then had to do was modify the detecton algorithms to better suit a turret, such as introducing rudimentary motion prediction, and stopping the software from rapidly switching between targets. It was also necessary to interface this program to the serial module, and provide a way of calibrating the turrets field of view to that of the webcam. I imagine I can provide the source if anybody is doing something similar, but from what I remember it is a pretty horrific concoction of ineffiencies and bad practise.

Here's the original coursework submission (.docx)

Comments (1) Trackbacks (0)
  1. WOW! I will keep an eye out for you, I can see better and greater things coming from you.

Leave a comment

No trackbacks yet.