Saturday, July 17, 2021

Cat Deterrent design notes

 The PIR detectors and tweeters arrived so I threw a rough prototype together, using a couple pieces of 4 x 1/2 wood for the base and vertical mast.  I used a single shelf bracket to assemble that part of the project.  Then I moved on to the electrical connections.  The PIR detectors have 3 male pins on the top edge, so I made two small receptacles using .1" headers soldered to small pieces of vector board.  I also had purchased a wall wart style power supply that outputs 5V and 12V.  The 5 volt supply runs the Arduino and PIR detectors, and the 12 volt supply is for the tweeter driver.

Speaking of the tweeter driver, I first planned on making a simple class AB audio amplifier, but realized that I don't need even semi-accurate sound production.  So instead I got an L293 quadruple half-H driver, typically used to drive DC motors.  It can output plenty of current and is a single-chip solution.  One side is directly driven by an Arduino digital output pin, and the other is an inverted version.  I used one of my (many) 2N3904 NPN transistors as an inverter.

After putting everything together I started playing with the software.  I quickly discovered that these PIR detectors are a bit noisy, outputting signals due to external interference.  Some browsing through the Web showed that this is a common problem.  However, it also appears that the noise susceptibility is greatly reduced if you minimize the lead length going to the detectors.  I can do this with the bottom detector but not for the top.  However, it looks like I can reject those phantom detect signals using software.  One issue is that, for a person, the top and bottom detectors don't switch at exactly the same time.  This complicated the software because there was a good chance the bottom detector would switch first, so just using that alone to identify a cat would be incorrect.

The other important observation was that, indeed, the PIR detector's field of view is so wide that the top detector was detecting cats -- so the system was incorrectly allowing cats to enter the "forbidden space".  I solved this by attaching another shelf bracket to the vertical board, just below the top PIR sensor.  Then I attached an aluminum sheet to the bracket.  This greatly improved the system's ability to discriminate between cats and humans.

One final thing I did in order to check how the system works in our absence was to get a wildlife camera.  I will set it up to monitor the cat deterrent system and modify things when I find problems with my implementation.

Here's a photo of my (messy) prototype:


The piezoelectric tweeter is resting on the floor.  My L293 tweeter driver board is to its left, and behind that, my Arduino board.

No comments:

Post a Comment