Pan/Tilt Laser Project

a.k.a. The Doodlator




Contact with any questions/comments.



I wanted to build a pan/tilt platform suitable for use with a small security camera, but before trying to attach a camaera to it, I decided to put a laser on it for fun.

The platform is moved with hobby servos, and the entire mechanism consists of a simple bracket on which the servos are mounted, with the base servo currently being secured (lightly) in a bench vice. The laser pointer has been modified by cutting off the battery compartment. It is now powered by the MCU's batteries, and is controlled with a transistor which is switched on/off with a pin on the MCU. It is mounted to a servo horn with a couple of zip ties. The on/off switch is mashed against the servo horn to keep it in the "on" position so that simply applying power to it via the transistor now turns it on.


I tried using long-exposure photography to capture the motion of the laser pointer to see how accurately the pan/tilt machanism could be controlled. It turns out that it's not super accurate (but obviously plenty good enough for security camera duty). The laser was pointed at a piece of black fabric at a distance of about 3 feet.

Some images from the initial experiments:

Yipes! That is some shaky laser action. For perspective, the images are about two feet across. This is nowhere near as smooth as I'd hoped, and the positional repeatability leaves plenty to be desired as well. There are several possible reasons for this:

1. Hobby servos just aren't precision instruments. Some jitter and slop is inevitable at this price point.
2. My pan/tilt mount isn't exactly a heavy, solid chunk of fine machine work. It is just a thin scrap of aluminum screwed onto some servos, and a servo control horn is a relatively floppy plastic arrangement to begin with. It would be far better to make a solid base with proper bearings for the points of rotation, and then attach servos (or some other actuators) to impart motion to the base. The servos are just too flimsy to be used as actual structural components of the base.
3. I'm using the ATmega168's built-in oscillator to generate the servo pulses used for positioning. I'm told that these oscillators are not nearly as accurate as crystals, and so it might be possible that some of the jitter is caused by drift in the pulses driving the servos. I've not done any testing to verify if this might be the case.

Here's a closer look. This is an arc of a circle, again with a radius of about a foot or more.


It is apparent from looking at the circles in the images above that quadrants II and IV suffer the most severe jaggies. Perhaps a sympathetic oscillation is induced in the base when traveling in these directions.

Of course that doesn't really matter much to me. I'm not doing laser surgery with this thing. It's just for fun and experimentation. Here are shots from more experiments:

3-petal rose
Lissajous figure
8-petal rose

The rose figures were generated with the formula R=cos(K*theta). The polar coordinates are generated by iterating theta from 0 to Pi for odd values of K, and 0 to 2Pi for even values of K. The polar coordinates are then mapped to the cartesian plane with the following formulae:
     x=R*cos(theta)
     y=R*sin(theta)
The rose at the top of this page was generated with K=7/6 while iterating from 0 to 12Pi with a step size of .001 radians. See this wikipedia page on rose figures for more info.

The Lissajous figure (above, center) was made using these formulae:
     x=sin(A*theta)
     y=sin(B*theta + C)
See this wikipedia page for more on Lissajous figures.

I debugged all the complex figures on a desktop computer prior to doing them on the microcontroller. Debugging is just so much easier that way. It gives additional benefits, such as the ability to animate the figures. I animated the Lissajous pattern by iterating the C element from 0 to 2Pi. Here it is as an animated .png:

(If you can't see the animation, you might consider upgrading to the latest of either the Firefox or Opera browsers.)

So far this project has been amazingly fun, but I'm not finished yet. I'll post more as I improve the platform and try different things.