Cat Repellent V2

by RobBest in Circuits > Microcontrollers

615 Views, 1 Favorites, 0 Comments

Cat Repellent V2

P1060470.JPG

This project is a modified version of the battery powered Cat Repellent that I posted earlier on Instructables. As mentioned there, I do not hate Cats but I love birds.

The reason for this version was that a Cat was sitting outside of the range of my previous Cat Repellent but it was sitting close to a mains outlet. So I decided to make a Cat Repellent version 2 that is mains powered. Because of having mains power it can produce a 40 kHz tone continuously and so keeping the Cats away. Although not required to save power, I did add a Passive Infra-Red (PIR) module to detect movement.

This version uses two different patterns when generating the 40 kHz tone:

  1. Normally the 40 kHz tone is 500 ms on and 500 ms off
  2. When there is movement, this changes to 100 ms on and 100 ms off for one minute or as long as there is movement. Also a 10 mm while LED will blink with the same repetition rate as the 40 kHz tone.

I used larger Piezo buzzers in this Cat Repellent, these are the types that you also find in the ultrasonic sensor module SR-04.

Supplies

Schematic_Diagram.png

You need to have the following components for this project:

A piece of breadboard

  • 1 * PIC microcontroller 12F615, including 8-pin socket
  • 2 * 40 kHz Piezo buzzer type TCT40-16T
  • 2 * BC639, 2 * BC640 transistors
  • 1 * 10 mm white LED
  • 4 * 22 Ohm, 1 * 330 Ohm, 4 * 1k, 2 * 10k resistors
  • 1 * 100 nF capacitor
  • 1 * 5 Volt power supply, at least 200 mA
  • 1 * Fuse, 100 mA/250V slow, including fuse holder
  • A plastic housing with integrated mains plug

See the schematic diagram on how to connect the components. The power supply, fuse and fuse holder are not shown in the diagram. 

The Design

Option_1.png
PIC_Capacitor.bmp
Piezo_Capacitor.bmp
Option_2.png
PIC_Driver.bmp
Piezo_Driver.bmp
No_DC.bmp

In order to get the highest range from the buzzers I used a half bridge mode to drive the buzzers. In this mode the two driving signals move in the opposite direction which doubles the voltage over the buzzer so it goes from 5 Volt to 10 Volt peak-peak. For generating the 40 kHz signal I used the Pulse Width Modulation (PWM) hardware of the PIC. This hardware also has the half bridge mode.

When driving a Piezo buzzer it is important that no DC component is present when the device is not in use. I investigated two options for driving the Piezo buzzers with both seem to work OK:

  1. Using a capacitor. This option is also used in my battery powered Cat Repellent that was mentioned earlier. In this situation the driving current comes from the PIC Microcontroller.
  2. Using transistors. In this situation the PIC does not have to drive the buzzers. I decided to use this driver circuit.

In the attached pictures you find schematic diagrams and screenshots of the oscilloscope of two options to drive the Piezo buzzers:

  • Option 1 with the PWM output signal of the PIC and the driving signal on the Piezo buzzer using a capacitor.
  • Option 2 with the PWM output signal of the PIC and the driving signal on the Piezo buzzer using the circuit with the transistors. When the signals changes, both transistors will be open for a very short time. In order to limit the current, the 22 Ohm resistors where added.
  • A picture that shows that there is no DC signal when the buzzers are inactive. This is achieved by setting the two PWM output lines of the PIC Microcontroller to input to switch of the PWM signal. The two pull-up resistors of 10k will make sure that the driver circuit is switched off too.

Building the Electronics

Board_Cropped.jpg

You can build the circuit on a breadboard. In the picture you can see the circuit as I built it on a breadboard. The fuse and the power supply of 5 Volt are also mounted on the board.

Important: Be very careful when building the Cat Repellent since the device is powered by the mains voltage!

The Software

The software is written in the JAL programming language for a PIC12F617. The software uses 151 bytes of ROM and 10 bytes of RAM. This fits easily in this small PIC who has 1k of ROM and 64 byte of RAM.

The software performs the following main tasks:

  • Generating the 40 kHz PWM signal. This signal is generated by the PIC PWM hardware using a timer. The main loop controls the on time an off time of 500 ms.
  • When movement is detected, for at least 1 minute:
  • Change the 40 kHz tone to 100 ms on and 100 ms off
  • Blink the LED with the same repetition rate

The PIC controller runs on an internal clock with a frequency of 4 MHz which is more than enough for this application.

The JAL source files and the Hex file for programming the PIC are attached. If you are interested in using the PIC microcontroller with JAL – a Pascal like programming language – visit the JAL website.

The Device in Action

Cat Repellent V2 Instructables

I made a short video of the device in action. Since you cannot see or hear a 40 kHz tone, I made a simply 40 kHz detection circuit using a Piezo receiver type TCT40-16R with an op-amp and a LED connected to it. In the video this circuit is laying on the floor in front of the Cat Repellent V2.

The video shows the following:

  • When no movement is detected the 500 ms 40 kHz tone is generated as is detected by the detection circuit on the floor
  • When movement was detected the 40 kHz signals changes to 100 ms and the LED on the Cat Repellent will blink with the same rate. The detection circuit will also follow this signal.

Have fun building your own project and looking forward to your reactions.