IR Tracking Turret with PIC and C




This is a good learning project that is fun to build – I got a lot out of making it. I think this has been done quite a bit already, but I did not find a straightforward way of doing this with PICs. When I finally got it working, I thought I’d share it. It might be useful for someone that wants to learn or apply I2C, Interrupts and Callbacks, PWM, or Servo Control.

Basic Functionality

Detects and tracks an infrared light source. Pans or tilts when the light source moves away from the center of the frame, attempting to keep it in the center.

Main Components

  • Pixart IR Camera
  • PIC16F1503 (a 14-pin, 8-bit PIC microcontroller)
  • Voltage Regulator
  • Servos

Assumptions

  • You can solder and desolder through-hole components
  • You have a computer
  • You can read a data sheet

IR Tracking Turret with PIC and CTake-Away Skills

  • 8-bit PIC programming in C using MPLAB X, XC8 and MPLAB X Code Configurator
  • I2C Protocol
  • Using microcontroller timers
  • PWM servo control, and getting maximum resolution in movement
  • Using an adjustable voltage regulator

You might also learn a little about

  • IR Wavelengths
  • Camera field of view
  • Using one power source for servos and microcontroller
  • Calibrating the Pixart camera module
  • Making something with room for expansion

No PCB etching required 🙂 I made this with stripboard and just cut traces and added jumpers where needed. It is also doable on a small breadboard. My first prototype fit the voltage regulator and main board components on one 17×10 breadboard.

This project should cost less than 25 EUR even if you have no spare parts laying around.

There are unused pins on the PIC16F1503 and I’ve included male headers for all pins in the stripboard pcb, so in-circuit programming is possible and there is room for expansion (another servo, more sensors, rocket launchers…).

Step 1: Tools and Materials

Most of this stuff you already have. You can use any sort of proto-board you want, but I recommend the strip kind for this project since I designed the PCBs using them.

Tools

  • Soldering Iron
  • Desoldernig braid
  • Small hacksaw
  • Heatshrink tubing ~5mm
  • Pickit3-compatible programmer

Optional Tools

  • hobby knife
  • debug header for PIC16F1503

Materials

  • Solder
  • Stripboard PCB
  • 10x20cm female-female breadboard wires
  • 6x10cm female-female breadboard wires
  • Assorted jumper wires
  • 4×1.5v batteries and holder (AA recommended)
  • 3V coin battery (CR2430 or CR2450 recommended)

Optional Materials

  • Double sided tape
  • Electrical tape
  • Tic-Tac boxes
  • ESD component capsules

Step 2: Components

You can find a broken WiiMote for cheap,I got one from Game Over in Amsterdam for 1 EUR. Broken WiiMotes are usually easy to find and the camera module is almost always OK – it’s the buttons that wear out.

Pixart Camera Board

  • 1.5×1.3cm pice of stripboard (6×5 holes, with 5 holes along the strip)
  • 6×1 male header
  • 3×2 or two 3×1 male headers
  • Something to pot the camera connections

For the camera module

Front of Camera (bottom view)

7 5 3 1
8 6 4 2

  • Remove it from the WiiMote – desoldering braid works best, but I did manage to remove two intact with a blowtorch 🙂
  • Clip pins 3 and 4 – we don’t need them
  • Nudge pins 5 and 6 a little toward the center and nudge the other as necessary to make them line up with the pins on the 3×2 or two 3×1 headers
  • Solder the camera pins to the header pins
  • Test the continuity of the connections
  • Pot the soldered connections in sugru, silicone, etc. – or just carefully wrap it with a piece of tape 🙂
  • Done!

Voltage Regulator Board

  • 2.4×1.2cm piece of stripboard (9×4, with 9 holes along the strip)
  • LM317
  • 240 ohm resistor (I used two 120 ohm in series)
  • 380 ohm resistor
  • .1 uF capcitor
  • 3300 uF capacitor (you can get this from the WiiMote as well, else anything comparable will do)
  • 4×1 male header

Main Board

  • 4x4cm piece of stripboard (15×15 holes)
  • 2x 7×1 make headers
  • 2x 6×1 male header
  • 4×1 male header
  • PIC16F1503
  • 25MHz oscillator
  • Red LED
  • 1x 220 ohm resistor
  • 2x 2.2K ohm resistor
  • .1 uF capacitor

Notes

Headers: Right-angle or straight will work – I actually wish I had used right-angle headers on the main board to keep things flatter.

Step 3: Design

This was intended to be an inexpensive learning project with room for expansion, simple enough to put on a small breadboard, programmed and assembled without too much difficulty.

Requirements

  • Tracks at least one beacon 1-4 meters away, and pans/tils to keep it in frame
  • Around a 20 EUR build
  • Relatively small and light (all boards, servos and wiring, without batttery ~40g)
  • Runs off 6VDC
  • Reacts quickly to movement
  • Broken into modules
  • Camera module board as small as possible
  • Room for expansion

As a bonus to you, there is also room for improvement 🙂

IR Tracking Turret with PIC and C Schematic

Why Stripboard?

I did not feel like making one from scratch for this – since the circuit is not very complex I thought I would tr to use proto board. I had worked out the circuit to be pretty compact on the breadboard and wanted to move it easily to the PCB, so I chose stripboard. With a few cuts and some jumpers I was able to keep things within 4×4 cm for the main board.

Why the WiiMote?

The camera module in the WiiMote uses an I2C interface and does all the heavy lifting for you. It provides pixel coordinates for up to 4 IR beacons, so you can easily figure out how much to pan/tilt to center the target. It has a high frame rate – something like 50 fps, so it can quickly detect and react to rapid movement. You can also configure it when initializing it to tune it to your use.

There are a lot of very informative sites out there that fully explain every aspect of this module. Finally – most broken WiiMotes have a fully functional camera inside and can be had for a buck or two. Cheap, readily available and does exactly what I needed for this build.

Why 8-Bit PIC?

They are powerful enough for this project, cheap and readily available in most regions. There is good support for both assembler and C. The development tools are all free. Programmers are reasonable. Plus, with the PIC16F1503 you can use code generation tools in MPLABX (Microchip’s programming IDE). Unfortunately this PIC does not have built-in debugging capabilities – you need a header to do that. But with this project you should not need one – it is pretty straightforward, and a good intro project for someone past the blinky stage.

 

For more detail: IR Tracking Turret with PIC and C




Leave a Comment

*
= 5 + 8

Read previous post:
The smallest thermal imager

https://www.youtube.com/watch?v=SKLnGhwWtoc&index=2&list=TL0JJoxPRjvm66fTqt8KmANqhlFqs-bf30 Freeing the Lepton from its Iphone prison!   For more detail: The smallest thermal imager  

Close
Scroll to top