Inline graphics on this page: 15K

Vision

Eyes are very important in nature - even small animals are rarely blind. That is why the Spider gets the best eye I could think of, within the limits posed by four criteria:

Weight- a few grams
Size- a few centimeters
Cost- a few dollars
Building time- a few minutes

Clearly, video cameras are out of the question. The sensitive part of the Spider's eye is in fact a humble LDR (light dependent resistor), looking through a 5 centimeter long black pipe, with an inner diameter of 5.5 millimeters. Yet it is capable of detecting moving objects with some accuracy!

The pictures below were made by a PC connected to the `thinking' part of the eye, an AT90S1200 microcontroller. A little program in the PC recorded light values reported by the eye, and emulated the motion detection algorithm written into the 1200. Light values are shown as green bars of proportional length; a red bar signals that motion has been detected.
In other words, it is as if you are looking through the Spider's eye.

A look through the Spider's eye

Above you see me sitting in front of the eye, 1 meter distance, wearing a dark shirt and moving my hand slowly in front of me. The shirt is providing the only contrast. Near the end you see me bend over to reach the keyboard for a screen grab. Moving objects much smaller or further away can be detected, but then the picture is not as detailed.

To be able to detect moving objects, the Spider has to be motionless itself. That may sound like a severe constraint, but remember that many real spiders and insects show similar behaviour; they wait motionless for something to approach, then pounce. The motion detection is not hampered by the sine wave present in most artificial light. That noise is suppressed by carefully synchronizing the eye activity with the noise frequency.

When the Spider is on the move, motion detection is switched off. The eye can than be used for radar-like scans of the environment, perhaps looking for a dark place to hide...

A second look through the Spider's eye

Above: A scan around the room (over about 200 degrees) with moving object detection switched off.

As you can see below, the eye hardware is very simple. Visitors from the past will notice that has gotten even simpler than before; a single ordinary i/o pin gives almost the same performance as the analog comparator used to do, the only casualty being easy adjustment of the hardware. Selecting the right capacitor for the chosen LDR has proved to be easy enough.
Most of the hard working stuff is inside the AT90S1200, a very capable yet cheap little micro-controller. For easy development the eye is combined with the programming hardware - just a few extra wires in the cable connecting it to a PC's parallel port. So how does the eye detect a moving object?

The cycle begins with i/o pin PB3 as an output, discharging the 10N capacitor to zero. Then PB3 becomes an input, which in this controller is equipped with a schmitt-trigger to deal with signals anywhere between the proper `1' and `0' levels. Right after the switch to input, a timer/counter is started. The LDR charges the capacitor. After a few milliseconds - the time depending on the light reaching the LDR - the schmitt-trigger signals high and the timer value indicates the present light level. The process is repeated 8 to 16 times per second (between light readings, the processor has time to do other things). When three levels in a row are each higher or each lower than the preceding one, a rising or falling edge is detected, and perceived as a moving object.
In the prototype, the motion detection algorithm halts all activity for about 0.4 seconds when it is triggered, and a `chirp' is emitted to mark the event.

Eye schematic

An explanation of the abbreviations is here if your need it.
NOTE: The value of the sample capacitor (10N) is correct for an LDR which varies between about 17K and 3M2 in the light to dark (white to black) range you need, when that LDR is mounted in a suitable `eye pipe'. My LDR came in a TO-18 case, fitting nicely in a black pipe with an inner diameter of 5.5mm. A length of 5cm gave the eye sufficient spatial resolution.

Eye PCB layout

Here you have a pcb layout for the prototype. The software as described here is not part of any robotic `thinking', but I believe it may be interesting on its own and useful for other purposes. The programs for both the AT90S1200 and the PC are available under the GNU General Public Licence. Here you have a self-extractor containing both sources and executables:

The complete eye package for Dos/Windows(dosMode)
And one for Linux, including a dynamically linked executable

NOTE: The hardware/software combination described here counts on the PC parallel port to provide between 3.5 to 4.5V at a few mA.

You will also need programmer software to write the controller program into an AT90S1200. This can be found on the previous page.

If you wish, the software can be made compatible with the well-known Kanda STK-200 and `dongle' by recompiling the source with -DKANDA. That allows you to improvise a Spider's Eye on the STK-200, with just the 10N cap and the LDR. In that case, you should use the Kanda programming software to write the controller program into an AT90S1200 on the STK-200.

Finally, a word of thanks to Ken Huntington, for providing a table of LDR characteristics and great feedback during development!

So how about an `ear', and integrating these sensors with some interesting Spider `thinking'? These matters are being pondered...

previous (Programming the brain) / next (Spider sound)