Monday, June 18, 2012

A recurring source of inspiration.

Almost eight years ago exactly I was married to my lovely wife.  When we moved-in together she brought with her two cats, orange tabbys, brothers.  Although they're named after characters from the TV series Bonanza they have become known as "The Fat One" and "The Dumb One".  That's not to imply that the Fat One is particularly clever or that the Dumb One is particularly svelte, but it's a completely accurate description of the two brothers.  The Fat One outweighs a bowling ball, and the Dumb One could be (and has been) out-smarted by a grasshopper.

Cats adjust poorly to new homes.  It takes a long time for them to become comfortable in the new, unfamiliar environment.  Behavior issues often develop when an adult cat is moved.  These two idiots manifested their discomfort by turning the furniture into a surrogate litter box.  They pee'd or pooped on every upholstered surface to which they had access, but of particular interest to the two butterballs was my wife's papasan chair.  It seems they took turns making trips to the water bowl and back to the chair.  After only a month of repeated cleanings and efforts to appease or repel the cats there was no salvaging the cushion on the chair, and it had to be discarded to save the rest of the house from smelling like a dirty diaper.

Here they are in the chair in question.  Notice the size of the beast on the left is approximately that of a Thanksgiving turkey.

We replaced the cushion on the chair with a brand new cushion in the vain hope that if it didn't smell like cat urine they might not treat it the same way.  We moved the chair to a different part of the room hoping that they may forget it was there.  My wife even made a water-proof cover for it just in case the behavior continued.  Less than a day after the cushion had been replaced the accursed felines were at it again.  It took them less than a week to realize that the water-proof cover was just a cover, and first the Fat One and then his not-quite equally obese brother managed to slip under the cover and hose the cushion once more.

It was time for a new approach.

I collect random stuff.  When I go to a hardware or kitchen supply store I simply can't leave until I've looked at the clearance section, and more than once I've taken something home that I didn't need at the time with either the expectation that I might need it in the future or the hope that I could take it apart and learn something.  It shouldn't be a surprise therefore that I happened to have a motion-detector driveway light and a servo motor in my random-crap box.  I made a trip to the dollar store and Radio Shack to get everything else I needed.  My design: a motion detector to "see" the cats, a spray bottle to "discipline" the cats, and a servo to pump the trigger on the spray bottle.

It took a bit of experimentation get all the parts to work together.  I didn't want to have to build a servo-driver circuit in addition to everything else I was doing, so I modified the servo to be voltage driven rather than pulse-width modulation (PWM) controlled.  Servos are designed to only have 180 degrees of motion which would be just fine if I were using it as a servo rather than just a gear-head motor.  I modified it to make it turn continuously in either direction.  (I'll make a special post on how I modify and control a servo at a later time)  I made a special armature for the servo from a heavy washer and a small bolt since the factory armatures that came with the servo were light plastic that folded under the stresses involved.  The bolt stands straight out from the washer so that as the servo turns it keeps hitting (and depressing) the trigger on the spray bottle.

I didn't have to do much to the motion detector.  It's powered by mains current (110V AC house current), and when the passive infrared (PIR) sensor detects something the module passes mains current directly through to two light sockets (which I removed to expose the wires).  I had hoped to power the servo directly from the motion detector (through a step-down transformer of course), but the shortest time I could get the motion detector to go "high" (conduct current to the wires previously intended for the lights) was five seconds which was WAY more time than I wanted the spray bottle to be continuously spraying.

A 555 timer is a very inexpensive, sturdy, and reliable integrated circuit that can be used to deliver a direct current (DC) of 3 - 12 volts for a precisely controlled period of time that can vary from extremely short to surprisingly long (milliseconds to hours).  I use them frequently in my electronics circuits, so don't be surprised if they keep appearing in my blog entries.  I won't bother posting a full tutorial about 555s on my blog.  Quite simply there are many very well done tutorials elsewhere online.  I'll put some links to a few at the bottom of this post.

I had a 9 volt power supply that had previously powered a neck massager I'd purchased at a thrift store (and subsequently took apart to scavenge components).  The output wires from the motion detector I soldered to the primary winding of the transformer from the power supply so that each time the output from the motion detector went "high" (the motion detector detected something) the power supply could deliver a steady 9 volts to a 555 timer circuit.
I built a monostable circuit using a 555 timer, modified the circuit to trigger automatically as soon as it received power from the 9 volt power supply, and calibrated the resistor-capacitor (RC) series to run for about about three seconds (see the circuit schematic I used below).  At 9 volts the modified servo would rotate completely three times without a load.  I didn't want to risk burning-out the 555 timer, so to power the servo I had the output of the timer actuate an SPST solenoid through which the servo received power directly from the 9V power supply.

This is the whole system.  There is no schematic symbol for a motion detector, and I didn't feel like drawing out the entire circuit for it.  Some of these parts were simply what I had at the time I was building the circuit.   The capacitors in particular.


Long explanation shortened for the attention-span impaired: Motion detector detects something.  It passes 110 volts AC for five seconds to a transformer that steps the current down to 9 volts DC.  A 555 timer activates as soon as it gets power closing a solenoid switch for 3 seconds (instead of the full five seconds).  Electricity passes through the closed solenoid switch powering a gear-head motor (a modified servo) which pushes the trigger on a spray bottle two to three times in three seconds.
Astonishingly, it worked perfectly the first time!  I made a frame out of a piece of PVC pipe I cut and flattened, and I mounted the device on a camera tripod for stability and so the height of the sprayer could be adjusted.  The cats learned very quickly that getting on the chair meant getting sprayed with cold water.






I wish I could say that the intended result of the entire project (behavior modification) had been achieved.  Unfortunately while my contraption worked perfectly the noise made by the modified servo motor was obnoxious, and the massive field of view of the motion detector meant that is was regularly triggering when someone (human sized) walked behind the chair, around the chair, or pretty much anywhere in the same room with the chair.  My wife got into the habit of unplugging the device when she got home in the evening, and she would neglect to plug it back in when she left the room.  As a result what the cats learned was only that they couldn't get on the chair during the day, but in the evenings it was safe.

Project was ultimately a failure, but the device was a success.  That's better than many of my results.







Suggested links:

It's kind of like this: http://twolumps.net/d/20110330.html

555 tutorial - http://www.sentex.ca/~mec1995/gadgets/555/555.html

One way to mod a servo (not mine): http://www.instructables.com/id/How-to-modify-a-servo-motor-for-continuous-rotatio/

I love Wikipedia.  A quick lesson on motion detectors: http://en.wikipedia.org/wiki/Passive_infrared_sensor

2 comments:

  1. If you hard wire the device, the wife can't turn it off

    ReplyDelete
  2. I give my wife credit for intelligence. She could figure out how to disable the power supply.

    ReplyDelete

Constructive feedback and comments are appreciated and encouraged. I'll try to answer any questions if I can. I only ask for civility and respectfulness, not just for me but also in response to other comments.