SDT (Stationary Defense Turret)
Most geeks will be aware of the 50th Anniversary of Doctor Who this weekend. For that occasion, I wanted to have my version of K-9 up and running. I hope to have a simple mobile security bot version operational Saturday, but this was a logical separate function point on the way.
(Note: Editing video now. Will add shortly.)
"SDT" originally comes from the phrase "Ignore the Shooty Dog Thingy" used by Anthony Head's character in the episode "School Reunion." The fact that it is a Stationary Defense Turret was a happy accident.
As a proof of concept, SDT exhibits the function that it set out to-simple, one-sensor human detection and targeting. It is limited in scope though. The range of effectiveness at the moment is at greatest a meter and a half. Reliably it is closer to .7 m.
The heart of the system is the Melexis 90614 which you see in place of K-9's red "probe" on the unit:
This is an I2C thermopile unit. This means it measures temperature at a distance by comparing the infrared wavelengths coming through its window with the measured ambient temperature of the unit and sends the result over 2-wire. To use it with an Arduino the regular I2C library doesn't work though, so you need to use the I2Cmaster.h library, which I've attached. Most of the heavy programming to get this unit to work as a thermometer was done by bildr.blog. Once you have a threshold for human temperature you can use programming similar to the distance sensor on an SHR "head" for targeting.
As mentioned, this is limited in range. Part of that is because the field of view (FOV) of this unit is 90°. That means that a) at a distance, human body temperature gets averaged into the ambient temperature pretty quickly, and b) at closer ranges, the unit fires the laser at more "targets" than it should.
There is a version of the sensor that has a much more limited (10°-12°) field of view, which would probably increase the accuracy and range. Thermopile sensors the likes of which are put in commercially available point-and-read thermometers are reasonably accurate at quite a distance. The narrow-angle sensor costs about twice as much as the one I got. When I'm working again I may be able to justify the expense but not unemployed just before the holidays. Also, there are non-I2C thermopile sensors available for about a third of what this unit costs with a more limited (45°,55° and 80°) FOVs but the output is analog and even with the more limited field, chances are sensitivity and accuracy wouldn't make it worth the immediate investment (I do plan on testing them eventually though.)
For triggering, I'm using the PIR sensors in the ears. This is a solution to the human detection problem-motion within range of the unit tells it to look for the human, body temperature tells it when to fire. (No sense in continuously sweeping the field of view-especially with a battery-powered unit.) The bi-directional nature of the PIR sensors probably would allow a more efficient seek-and-sweep (ie, if the left ear is triggered and not the right then the head would start the sweep on the left.)
The laser is a stock eBay Chinese Green pen-pointer that I cut in half with a pipe cutter. The Arduino doesn't give you enough power to run it off of a Dpin, so there's a 2N2222 triggered by the Arduino pin across the full 2.1Amps from the power supply.
Sketch is below. Keep in mind that the UNO uses A4 and A5 for I2C, and that there are pull-up resistors to the I2C lines. See the bildr link above for pin-out. This is the third iteration of the code. I never cleaned up a lot of the dropped variables or commented lines. Keep in mind that using PIRs on a moving platform is a trade-off. I let the neck stabilze for 10 seconds after a targeting sweep to make sure any motion detected isn't self generated. Also, the zap function is triggered at anything above body temperature (mine is 97.1° F) but conceivably this could leave the dog firing at a furnace, so I had an upper limit option as well (commented out.) In the video, you can see it almost always shoots at the soldering iron and the furnace wall (behind the TV.)