ATM18 Youth Repellent Schematic Circuit Diagram
From what’s written on the cover of Bert van Dam’s book entitled “50 New Applications for PIC Microcontrollers” , some of you might think that the projects, which address programming 16/18 PICs in JAL in a well-paced and very detailed way, are not really compatible with your favorite processor and programming language.
But then again, maybe you’d like to produce all these applications without diving into a new language and without investing in a new programmer. So, why not draw inspiration from the author’s ideas, while still remaining faithful to your usual s/w tools and h/w bits? It would be a shame to pass up on a good, appealing project.
The description of the youth repellent circuit described here begins with these words: “Have you ever dreamt of a non-violent way of driving away those groups of noisy indolent youngsters who are always hanging about under you peaceful windows? […] If you are an adolescent, this project will enable you to produce a secret signal, inaudible to adults!”
The very high-pitched sound at 16 kHz that generated by this project will be unpleasant above all for adolescents and young children whose hearing is still unimpaired. The principal ingredients are an ATM18 board  and a sounder connected to PC0 on the ATM18 in series with a 100 Ω resistor. Sprinkle the whole thing with a little firmware written in BASCOM-AVR and we get our ‘youth repellent’.
The piezoelectric sounder has a diaphragm connected to a crystal. Here one pin of the microcontroller is employed to make this diaphragm vibrate at a certain frequency and thus emit a sound that we’re going to arrange to make unbearable.
Timer0 is used to produce a square wave signal at a defined frequency. The timer is incremented each time a pulse is received, and an interrupt is triggered when the register overflows. The register containing the state of the counter is write-accessible, so it is possible to set an initial preloaded value that will modify the overload frequency. Since the overflow resets the counter to zero, the interrupt routine will need to load the register each time with the starting value.
The 16 MHz quartz crystal clock frequency requires the use of a prescaler. Pre-dividing by 8, and if PC0 is inverted each time timer0 overflows, the formula
f = 16 × 106 / 8 / preload_value / 2
will enable you to directly obtain the sound frequency as a function of preload_value. In theory, a value of 62 will allow generation of a frequency of 16.1 kHz.
However, the tasks inherent to the operation of the take a certain amount of time, leading to a difference between the theory and reality. So in practice, you need to use a preload_value of 55 to arrive at a frequency of 16.1 kHz.
The circuit suggested by Bert lets you reduce the sound card’s maximum microphone input voltage from 5 to around 0.9 V. Take care, a wiring error here could cause irreparable damage to your PC. After downloading and unzipping the file (available free from ), copy/paste the file VBRUN300.DLL from the ‘Signal Generator’ folder into the ‘Frequency Analyser’ folder. Your PC’s microphone must be enabled and the volume control set to maximum.
Before powering up the whole assembly, set potentiometer P1 of the protection interface to zero. Double-click on the executable file Analyser.exe, then click on ‘Run’ to start the program. Turn the potentiometer until a peak appears in the signal. Click with your mouse near the peak to move the blue line. The little red line shown in the screenshot will look for the strongest signal in the vicinity of the blue line. The values are visible at the bottom right, next to the ‘Stop’ button.
Once this project is finished, do like Bert, wait until your children come to visit you in your study, innocently power up the circuit, and wait… You won’t have to wait long for their reactions and there’s no appeal against the verdict: your repellent works!
Note: the use of this sort of device is prohibited in certain countries.
Internet Links www.elektor.com/products/books/ microcontrollers/50-pic-microcontrollerprojects.1350471.lynkx  ww.elektor.com/071035  www.elektor.com/110397