— R3 would still limit the current to under 25 mA.
Another area of concern was the inductive kick from
the speaker. Even with a three volt supply, I measured
around five volts peak from some speakers. This high a
voltage above VDD might damage the chip.
The normal approach to this would be to place a
diode (like 1N914) between the positive power supply
(pin 1, VDD) and pin 6, as well as another diode between
pin 7 and pin 1. The diodes would be oriented to conduct
whenever pin 6 or 7 is a higher voltage than the positive
power supply; thus removing any spikes.
The only problem with this solution was that many of
my beginning electronics students frequently solder diodes
into circuits backwards because they don't fully
understand what they are doing. This raised the question,
"Are the protection diodes really necessary?"
In order to answer that question, both pins 3 and 4
were grounded to make the AOM output a series of rapid
beeps. The unit was tested for three weeks with supply
voltages ranging from 2.2V to 5.5V. After millions of beeps
— roughly 1,000 times more beeps than the unit will
produce in a month of normal operation — my AOM
continues to work without problems.
For those who would like to modify the design to
shorten the delay times and increase the pitch, change C2
from 500 pF to 330 pF. This would cause the pitch of the
tone to start at 3 kHz and be 5 kHz by the end of the
battery's life. The delay times would range from two
minutes to five minutes with fresh batteries, and two to
three minutes by the end of the battery's life.
Values larger than 500 pF result in a slower instruction
clock with a lower pitched tone and longer delays. Values
less than 500 pF result in a faster instruction clock with a
higher pitched tone and shorter delays. For those who
wish to try things out, try values for C2 from 1,000 pF
(0.001μF) to 200 pF.
Another area for modification is changing R2 to be a
5KΩ resistor in series with a 100KΩ potentiometer. An
increased resistance results in a slower instruction clock,
and lower resistance results in a faster instruction clock.
For the PIC's RC clock, R2 must be a minimum of 5KΩ, to
a maximum of 100KΩ.
Should you settle on a faster instruction clock,
remember that a faster clock results in increased current
consumption. If you chose to use a 330 pF capacitor for
C2 or reduced resistance for R2, you may wish to use the
larger capacity AA batteries rather than the lower capacity
Over the last 1-1/2 years, I've had roughly 100
students build this project. Based on their suggestions,
several variations were tried and minor improvements to
the design were added.
One of the best suggestions was to generate a multi-tone chirp. If you look at the source code available at the
article link, you'll see that a chirp starts at 2 kHz and then
36 April 2015
All Electronics 818-997-1806
14928 Oxnard Street www.allelectronics.com
Van Nuys, CA 91411
701 Brooks Avenue South www.digikey.com
Thief River Falls, MN 56701
Jameco Electronics 650-592-8097
1355 Shoreway Road www.jameco.com
Belmont, CA 94002
Mouser Electronics, Inc. 817-804-3888
1000 North Main Street www.mouser.com
Mansfield, TX 76063
Datak Protoboard Information:
Most software pseudo random number generators
simulate a shift register with taps at different points. The
taps are XORed and form the input to the shift register.
The other approach is to use a look-up table to read
random numbers. Due to the limits inside the PIC's
memory, a 256 byte random number look-up table was
about the biggest I could create. This sequence would
repeat roughly every day.
In order to make the table look bigger, I have two
pointers moving through the table. The first pointer moves
forward through the table reading each number, and the
second pointer moves backwards through the table
reading each number. To generate a difference after 256
bytes, the second pointer does not move when the first
pointer is at position zero. In addition, in order to generate
a different sequence of numbers from the second pointer,
the upper and lower nibbles are swapped and some bits
are inverted on the second pointer's output.
Both pointers return two different random numbers,
where one random number is subtracted from the other.
The end result is a string of eight-bit numbers that does not
repeat until 65,536 numbers later. I'm sure a cryptographer
could find a pattern to this sequence, but the average
person will have no idea what the next number will be.