This is only a preview of the April 2023 issue of Silicon Chip. You can view 39 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "500W Class-D Mono Amplifier":
Items relevant to "Wideband Fuel Mixture Display Part 1":
Items relevant to "Automated Test Bench":
Items relevant to "Silicon Chirp – the pet cricket":
Purchase a printed copy of this issue for $11.50. |
Silicon Chirp
the pet cricket
By John Clarke
This pet cricket will keep you company; it only needs to be fed
occasionally and won’t run away. Keep it for yourself or play a prank on
a family member or friend by hiding it in their room. When they switch
the lights off, they will get a bit of a surprise!
C
rickets, frogs and canaries
tend to be organic, made from
tried-and-tested construction
materials such as DNA and proteins.
Until now, that is. Silicon Chirp, the
electronic cricket, sounds like a real
cricket. Not only is this project fun, it
totally (and unexpectedly for a cricket)
mimics frog and canary sounds. With
very few parts, it is easy and fun to
build.
Silicon Chirp loves to sing in the
dark and happily chirps away, much
to the annoyance of others. When disturbed by light, (s)he ceases, thus hiding their whereabouts until darkness
falls again. But (s)he does not immediately begin to chirp again when
darkness falls. That could take up to
40 seconds.
And as you enjoy the peace and
when all thoughts of an annoying
cricket drift away...chirping starts.
And so begins the hunt for that pesky
critter. Catching its glinting eyes in
the dark, you are faced with a predicament: remain petrified and unable
to move, or face that terrifying sight!
When the novelty of cricket sounds
wears off, it can be changed to a frog,
croaking in the dark. Or, for something completely different, change the
sound to a singing canary to brighten
your day.
You might think that the name bears
a remarkable resemblance to our magazine, but we assure you, it is purely
coincidental. The name comes from
the fact that the workings to produce
the cricket sound are based upon silicon DNA. Also, it produces a chirping sound. Hence the name: Silicon
Chirp.
As mentioned, Silicon Chirp can
produce the sound of a frog or canaries and, of course, a cricket shape is
inappropriate when making these
alternative sounds. We considered
having three separate PCBs with different shapes, but swapping parts
from one to the other seemed impractical.
Then again, the Bower Bird still
looks like a bird, even when making
sounds like a chainsaw or a car alarm.
So, this cricket is a keen ventriloquist, mimicking the sounds of other
animals while remaining in the cricket
shape. It’s so talented that its legs and
mouth don’t even move while making those sounds! You could place a
frog or bird toy near Silicon Chirp to
make the ventriloquism seem all the
more real.
Features & Specifications
] Looks and sounds like a cricket
] Also has the option to produce frog or canary sounds
] Flashing red eyes
] Can be set to only operate in the dark (or light, in canary mode)
] Low current draw from 3V lithium coin cell
] Current draw: 0.4μA while dormant, 0.48-1.7mA during chirps
72
Silicon Chip
Australia's electronics magazine
For the cricket, most components
are mounted on Silicon Chirp’s back,
with its eyes being 3mm red LEDs.
The piezo transducer that produces
the sounds is slung under the PCB
abdomen. Six legs are fashioned from
thick 1.25mm copper wire, while the
two antennae and ovipositor (tail) are
made from a thinner gauge wire.
Cricket sounds
Crickets produce chirping sounds
by rubbing a coarse section of one wing
against a scraper on the other. This process is called stridulation; it’s a bit like
running a stick along a picket fence or
old-fashioned washboard.
Typically, the sound a cricket produces comprises three closely spaced
chirps, followed by a longer gap, then
another three and so on (ie, they have
a particular pattern or cadence).
A typical cricket chirp comprises
four bursts of a 4kHz tone, each lasting
for around 50ms. The spacing between
each chirp is also about 50ms, while
the separation between each triplet is
around 250ms.
These periods are not precise and
do vary a little. However, the tone of
the chirp does not appear to vary by
any noticeable degree.
Silicon Chirp follows the same
pattern, with triplets of 4kHz bursts,
each separated by a longer gap. However, we found that driving a piezo
transducer with three 20ms bursts at
4kHz and with 20ms gaps between
them produced the most authentic
cricket sound, even though the 20ms
siliconchip.com.au
Scope 1: cricket-like chirping is simulated by driving the
piezo with groups of three signal bursts spaced apart by
around 20ms. These groups have much longer silent periods
in between them.
periods are different from that of an
actual cricket.
Scope 1 shows Silicon Chirp’s
cadence as measured by an oscilloscope.
To act like a real cricket, the chirp
rate must vary slightly rather than
being at precise intervals. So Silicon
Chirp’s chirping periods vary randomly over a limited range. In other
words, they aren’t always exactly 20ms
long or spaced apart by precisely 20ms.
The variations in the periods provide a
more natural cadence and prevent the
simulated cricket chirp from sounding artificial.
Frog sounds are produced similarly
but with a different cadence to the
cricket. For Silicon Chirp, frog sounds
comprise a set of 10 chirps, 10ms long
with 2ms gaps.
This is followed by a 30ms gap and
then another set of three chirps. The
ten and three groups are separated by a
delay of 200-1200ms that varies irregularly. The frequency of the chirps is
set at around 2kHz.
The canary sounds have been
divided into three types, designated
A, B and C. Song A sounds like a typical canary, while Song B simulates a
Fife canary. Song C is a selection that
comprises various single phrases produced by these birds.
The canary sings at random. Each
song is repeated between two and
27 times with a 2.4 to 17 second gap
between them. There is an extended
gap between each series of repeated
songs, between 80 seconds and nine
siliconchip.com.au
Scope 2: a close-up of the drive to the piezo, showing how
the 3V peak-to-peak square wave signals from the RA0 &
RA1 outputs (yellow and cyan traces) combine to produce
a 6V peak-to-peak square wave across the transducer (red
trace).
minutes. Like the cricket and frog, the
bird songs are produced by varying the
frequency, volume and length of bursts
of pulse trains applied to the piezo.
The sound volume is varied by
changing the pulse width of the signals
applied to the piezo transducers. Narrow pulses give a low volume, while
wider pulses make more sound. Maximum pulse width equates to a duty
cycle of 50%.
Each chirp starts at the minimum
pulse width, increasing to the required
volume level over time. Similarly, the
pulse width is reduced to zero over a
short interval when a chirp or tweet is
about to end. This avoids clicks from
the piezo transducers, which would
otherwise spoil the effect.
Unlike crickets and frogs, which
tend to make noise when it’s dark, bird
sounds occur mainly when it is light.
So the light/dark detection is inverted
for the canary.
Circuit description
The complete Silicon Chirp circuit
is shown in Fig.1. It’s based around
microcontroller IC1, a PIC16F15214-I/
SN, powered by a 3V lithium cell,
switched via slide switch S1. IC1 does
not draw much current, typically only
about 400nA while it is dormant. This
rises to between around 480μA to
1.7mA while making noise.
Diode D1 is included as a safety
measure to prevent damage to IC1
should the cell be inserted incorrectly.
The correct polarity is with the positive side up, but the cell holder will
accept the cell in either orientation.
With the positive side down, the
cell will be shorted out by contact
with the sides and top spring contacts.
The underside of Silicon Chirp,
showing the large piezo transducer.
Feel free to customise the board to
suit your taste. Note the on/off
slide switch near the ‘tail’.
April 2023 73
However, during insertion, there could
be a brief period when there is no
contact with the cell holder sides, so
the circuit could be supplied with a
reversed voltage polarity that could
damage IC1.
Diode D1 clamps any reverse voltage
to a low level. The cell will lose some
capacity if left connected in reverse
for more than a few seconds, but that’s
better than damaging the IC.
IC1’s power supply is bypassed with
a 100nF capacitor and runs using its
internal 4MHz oscillator. When dormant, this oscillator is shut down
(ie, in ‘sleep mode’) to save power.
A ‘watchdog’ timer starts running to
wake IC1 periodically (at approximately four-second intervals). During
this period, the current consumption
is typically less than 1µA.
During the waking period, IC1
checks the ambient light level on the
light-dependent resistor, LDR1. Most
of the time, the RA5 output (pin 2)
of IC1 is set high (3V), so there is no
current flow through the 470kW resistor and the LDR to minimise the current drain.
When IC1 is awake, it sets the RA5
output low (0V) and the LDR forms a
voltage divider with the 470kW resistor
across the 3V supply. The RA4 digital input (pin 3) monitors the voltage
across LDR1.
In darkness, the LDR resistance is
high (above 5MW), so the voltage at
the RA4 input is more than 2.7V due
to the voltage divider action of the LDR
and the 470kW resistor. This voltage is
detected as a high level by IC1. With
sufficient light, the LDR resistance
drops below 10kW, so the voltage
divider produces a low level of 63mV
or less at the RA4 input.
The thresholds for the RA4 input
are 20% of the supply voltage for low
and 80% of the supply for high. It
is a Schmitt-trigger input, so once it
exceeds the high threshold, the voltage
must drop below 20% of the supply to
switch to low. Similarly, once detecting a low, the voltage must go above
80% of the supply before a high level
is indicated.
That ensures there is no rapid
switching between high/low state
detection when the voltage is between
these thresholds.
Driving the piezo transducer
IC1’s RA0 and RA1 digital output pins (pins 7 & 6) drive the piezo
transducer that produces the chirps.
The piezo is driven in bridge mode,
connected across these two outputs,
which increases the AC voltage to produce a louder sound.
When RA0 is driven high, the RA1
output is taken low; when the RA0
output is low, RA1 is high. In one condition, there is +3V across the piezo
transducer and in the other, -3V, producing a 6V peak-to-peak square wave,
shown in Scope 2.
Scope 2 is a close-up of the 4kHz
drive waveform fed to the piezo
sounder. Channels 1 & 2 (yellow and
cyan traces) are the signals applied
at either end of the piezo transducer,
while the red trace shows the total. So,
while each end of the piezo is driven
by a 3.28V peak-to-peak waveform,
there is double that voltage produced
across the piezo.
A 100W resistor limits the peak current into the transducer’s capacitive
load immediately after the outputs
switch.
LED1 and LED2 are driven via the
RA2 (pin 5) and RA5 digital outputs
with 330W current-limiting resistors.
These LEDs are driven alternately on
and off while the piezo transducer is
driven. When RA5 is low and RA2
high, LED1 is lit, while when RA5 is
high and RA2 is low, LED2 lights.
Note that RA5 is also used to drive
the LDR (LDR1) to monitor the ambient
light level. When driving RA5 low for
light measurement, RA2 is also set low,
so the LEDs are off. Similarly, when
the LDR is off (RA5 high), RA2 is also
brought high to keep the LEDs off.
Pushbutton switch S2 changes the
Fig.1: Silicon Chirp is controlled by 8-bit PIC16 microcontroller IC1. Slide switch S1 applies power from the coin cell. It
then uses LDR1 to sense the light level and, depending on what it finds, produces sounds by driving the piezo transducer
from its pin 6 & 7 digital outputs while flashing the eye LEDs via the pin 2 & pin 5 digital outputs.
74
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
siliconchip.com.au
TOP VIEW
WITH LEGS, TAIL
AND ANTENNAE
100W CON1
SCREW &
STANDOFF
S2
LED1
K
LDR1
+
PIC16F15214
CELL
CAPTURE
CR–3032
Silicon Chirp is built on a double-
sided, plated-through PCB coded
08101231 that measures 94 × 30.5mm.
Wire legs are soldered to this PCB so
it ‘stands up’ like a real cricket. These
wires and the other parts are shown
in Figs.2 & 3.
Typically, in-circuit serial programming (ICSP) header CON1 is not
installed; if you build it using a PIC
supplied by us (by itself or as part of
a kit), it will come pre-programmed,
so programming will not be required.
If you need to program a blank micro,
ICSP header CON1 can be installed.
Screen printing for this is on the
underside of the board (for aesthetic
reasons); however, it needs to be
installed from the top since only the
underside of the PCB has exposed
pads for soldering. The top layer pads
are masked, also for aesthetic reasons.
Ideally, you should remove the ICSP
connector after programming, as real
crickets do not tend to have a programming connector.
Begin by installing the surface-
mounting microcontroller, IC1. You
will need a soldering iron with a fine
tip, a magnifier and good lighting.
The use of flux paste during soldering
is advised, in which case you don’t
necessarily need a very fine soldering iron tip.
Solder IC1 to its PCB pads by first
placing it with the pin 1 locating
dot to the top left, positioning the IC
leads over their corresponding PCB
pads. Then tack-solder a corner pin
and check that the IC is still aligned
correctly. If it needs to be realigned,
remelt the soldered connection and
gently nudge the IC into alignment.
Once correct, solder all the IC pins
and refresh that initial joint. Any solder that runs between the IC pins can
be removed with solder paste and the
application of solder-wicking braid.
Continue construction by installing
the resistors. They are printed with a
code indicating their values, which is
1 double-sided, plated-through PCB coded 08101231, 94 × 30.5mm
1 CR2032 surface-mounting coin cell holder (CELL1) [BAT-HLD-001]
1 CR2032 3V lithium cell
1 SPDT micro slide switch (S1) [Jaycar SS0834]
1 SPST surface-mounting tactile pushbutton switch (S2)
[Altronics S1112A, Jaycar SP0610]
1 30mm diameter 4kHz wired piezo transducer (PIEZO1)
[Altronics S6140, Jaycar AB3442]
1 45k-140kW light dependent resistor (LDR1)
[Altronics Z1619, Jaycar RD3480]
3 M3 × 10mm panhead machine screws (metal or plastic)
1 M3 × 6.3mm tapped Nylon spacer (or two M3 hex nuts)
2 Nylon or polycarbonate M3 hex nuts
2 TO-220 insulating bushes (eg, from TO-220 insulating kits)
[Altronics H7110, Jaycar HP1142]
1 6-way header with 2.54mm pitch (CON1; optional, for programming IC1)
1 200mm length of 1.25mm diameter enamelled copper wire (for legs)
1 100mm length of 1mm diameter enamelled copper wire
(for antennae & ovipositor)
Semiconductors
1 PIC16F15214-I/SN 8-bit microcontroller programmed
with 01810123A.hex, SOIC-8 (IC1)
2 3mm red LEDs (LED1, LED2)
1 LL4148, MM4148 or 1N4148WS (or 1N4148; see text) SMD diode,
Mini-MELF (SOD-80) or SOD-323 [Altronics Y0161/Y0164A]
Capacitors
1 100nF 50V X7R SMD M3216/1206 size
Resistors (all M3216/1206 size 1%)
1 470kW
1 330W
1 100W
IC1
LED2
A
100nF
BOTTOM VIEW
(JUST THE PCB)
PIEZO1
470kW
S1
D1
PIEZO1
Construction
Parts List – Silicon Chirp Cricket
CELL1
sound produced from cricket to frog or
canary. IC1 detects when S2 is closed
by monitoring digital input RA3 (pin
4). When S2 is pressed, the voltage at
that pin goes to 0V. When the switch
is open, the internal pull-up at RA3
keeps that input level high. The S2
switch closure is only checked during
power-up; changing the sound can
only be done then.
330W
Figs.2 & 3: Silicon Chirp is pretty easy to build. Simply place the components as
shown here but note that the piezo transducer is wired and mounted over reverse
polarity protection diode D1. That diode, IC1 and the LEDs are polarised and
must be soldered the right way around; the other components are not polarised.
Australia's electronics magazine
April 2023 75
Silicon Chirp should look similar to this
when yours is finished, but feel free to
customise it to suit your taste. Note that
the CR2302 cell is secured using one
screw as a preventative measure
against tampering, so children
can’t get a hold of the
cell by itself.
likely to be “1000” or “101” for 100W,
“3300” or “331” for 330W and “4703”
or “474” for 470kW. These are in ‘scientific notation’ where the last digit
indicates the number of zeros to add
to the first few digits to give a value
in ohms.
Diode D1 can be installed next, taking care to orientate it correctly, with
the cathode stripe facing away from
the centre of the PCB. There is sufficient pad area to allow Mini-MELF
(SOD-80) or SOD-323 package diodes
to be soldered in. Alternatively, an
axial-leaded 1N4148 could be used
with the leads at each end bent back
by 180° to allow soldering to the PCB
pads.
The 100nF capacitor can be fitted
next, and it can be positioned either
way round as it is not a polarised part.
We installed slide power switch
S1 on the underside of the PCB. You
could place this on top if you prefer. The on position for the switch is
when the slider is toward the front of
the cricket. You can also mount pushbutton switch S2 now by soldering its
four pins.
The cell holder (CELL1) is a halfshell type and its body makes contact
with the positive side of the cell. A
tinned copper area on the PCB completes the cell holder and provides for
the negative connection to the cell.
It must be fitted with the cell entry
toward the rear of the cricket so that
the cell capture screw prevents small
children from removing it.
This is to comply with Australian
Standard (AS/NZS ISO 8124.1:2002),
where toys for children three years and
younger must have any batteries (and/
or cells) secured in a compartment by
a screw. Alternatively, where there is
no compartment screw used, there
must be two simultaneous independent movements to open the battery
compartment.
While Silicon Chirp is not really
a project for small children, it could
be used in a household with children
who could potentially swallow button or coin cells, which poses a serious hazard (see the warning panel
for details).
For our project, cell removal is
blocked by a 10mm M3 machine
screw inserted from the PCB’s underside and secured on top with an
M3-tapped Nylon spacer. When tightened, the spacer cannot be removed
by hand and stops the cell from being
removed. An alternative to the standoff is to use two M3 nuts, with the
top one used as a lock nut, tightened
against the other.
Mount LED1 and LED2 so that the
top of the dome of each LED is raised
off the PCB by about 10mm. This provides enough lead length so they can
be bent to about 30° above the PCB
plane and outward about 10° from the
centre line, as shown in Fig.2 and the
SC6620: Silicon Chirp Kit ($25 + postage)
A complete kit with all the parts in the parts list except the lithium coin
cell & programming header. Available from the Silicon Chip Online Shop.
76
Silicon Chip
Australia's electronics magazine
photos. Make sure the longer lead of
each LED (the anode) is inserted in the
“A” position on the PCB.
Mount the LDR about 5mm above
the PCB surface, with its face sitting
horizontally. This component is not
polarised and can be installed either
way around.
The piezo transducer is mounted on
the underside of the PCB, supported
on TO-220 insulating bushes that are
used as spacers to raise the transducer
from the PCB. This leaves room for
the cell capture screw and diode to fit
between the PCB and piezo. The piezo
transducer is secured with two 10mm
M3 machine screws and two Nylon or
polycarbonate nuts.
You will need to drill out the mounting holes on the piezo unit to a 3mm
diameter to suit the M3 screws. The
nuts will not fit in the room provided
on the piezo transducer mounting lugs,
so the screws need to enter from the
piezo transducer side. The insulating
bushes can then be slipped onto the
screw shafts, followed by the piezo
transducer, then the Nylon or polycarbonate nuts.
We use plastic nuts because a metal
nut will short out the cell if used at the
end of the cell nearest to IC1. That’s
because the PCB hole and surrounding
track are connected to ground, while
the metal of the cell holder connects
to the cell positive. To avoid confusion
and prevent the wrong type of nut from
being placed at each point, we specify
both piezo-securing nuts as plastic.
Note that to remove the cell capture screw when the cell needs to be
replaced, one of these piezo mounting
screws will need to be removed so that
the piezo transducer can be swung out
of the way.
Solder the piezo wires to the underside of the PCB at the positions marked
“PIEZO1”. You could instead bring
them to the top of the PCB and solder them through the corresponding
top holes, although that will look a
bit messy. The wires will need to be
shortened, but leave sufficient length
for the piezo to swing out of the way
to access the cell capture screw.
The piezo transducer wires will
probably be red and black, although
the transducer is not a polarised component. It does not matter which colour
wire goes to the two piezo PCB pads.
Legs and antennae
The legs can be fashioned from
siliconchip.com.au
1.25mm diameter enamelled copper
wire. Each front leg is 40mm long,
while the mid and rear legs are each
30mm. These can be as simple or as
fancy as you like. The cricket shape
printed at the rear of the PCB shows
the general leg shape we used, as do
Fig.2 & the photos.
Bend the legs so that Silicon Chirp’s
PCB is above the platform it sits on.
Form the feet into small loops so that
the sharp ends of the wires are not
exposed.
Where the legs are soldered to the
PCB, you will need to scrape off the
enamel insulation (eg, using a sharp
hobby knife or fine sandpaper) before
you can solder them.
Make up the two antennae using
40mm lengths of 1mm diameter enamelled copper wire and the ovipositor
(tail) with a 20mm length of the same.
Once in place, curl the two antenna
wires into shape by running a thumbnail along the inside of the radius, with
your index finger on the outside.
Now install the CR2032 cell in its
holder and switch on power with S1.
If all is well, the LEDs will momentarily flash after about three seconds
to acknowledge that power has been
connected.
An acknowledgement by a brief
flashing of the LEDs also occurs when
a low light level is detected for the
cricket and frog, or when a high light
level is detected for the canary. Low
light can be simulated by covering
over the LDR, or a higher light level
by shining light onto the LDR.
Silicon Chirp will begin chirping
after a delay of about 10 seconds, providing the low light level remains for
the whole time.
If you need to program the PIC yourself, you can download the firmware
Warning: small cell
This design uses a small lithium cell that can cause severe problems if
swallowed, including burns and possible perforation of the oesophagus,
stomach or intestines. Young children are most at risk. Read the
information sheet at www.schn.health.nsw.gov.au/fact-sheets/buttonbatteries on the dangers of button cells.
Ensure that the cell is kept secure using the cell capture screw and
Nylon spacer as specified, tightened sufficiently so they cannot be undone
by hand. Keep unused cells in a safe place away from children, such as a
locked medicine cupboard. New cells should be kept within the original
secure packaging until use.
Unfortunately, some older button cell powered devices not intended for
children under three provide easy access to the cells. Keep these away
from children or devise a method to make cell access more difficult (eg, by
gluing the compartment shut).
(01810123A.hex) from the Silicon
Chip website. Additionally, as mentioned previously, ICSP (in-circuit
serial programming) header CON1
will need to be installed. One of the
piezo transducer leads may need to be
disconnected, or one end of the 100W
resistor, to allow programming.
expressed with the piezo transducer
close to a flat surface to emphasise
lower frequencies. The canary sounds
run through a repertoire before switching off when darkness is detected, so
they won’t necessarily stop as soon as
the light goes away.
Changing the sound
Silicon Chirp has a loud chirp,
which can be pretty annoying! (But
maybe you want that...) To reduce the
volume, increase the value of the 100W
resistor in series with the piezo transducer. Increasing it to, say, 10kW will
reduce the apparent volume by about
50%. Higher values will provide an
even lower volume, to the point where
it won’t chirp at all.
The light sensitivity can also be
altered by changing the 470kW resistor value between the positive supply
and the PIC’s RA4 input. Increasing
the resistance value (say to 1MW) will
make the light threshold level darker.
By contrast, reducing the resistance
value will mean more light is required
SC
to detect daytime.
Changing from cricket to frog to
canary and back is performed by
holding switch S2 while switching
power on via S1. Continue to hold S2
until you see the eyes flashing. They
will flash once for the cricket, twice
for the frog and three times for the
canary. To change to the next selection, continue holding S2 for two seconds until the eyes flash to show the
next selection.
When you see the selection you
want, release S2. The selected sound
is stored in flash memory, so that selection remains even if powered off and
on again. It only changes when S2 is
pressed during power-up.
Note that the frog sounds are best
Modifications
Raspberry Pi Pico W BackPack
The new Raspberry Pi Pico W provides WiFi functionality, adding
to the long list of features. This easy-to-build device includes a
3.5-inch touchscreen LCD and is programmable in BASIC, C or
MicroPython, making it a good general-purpose controller.
This kit comes with everything needed to build a Pico W BackPack module, including
components for the optional microSD card, IR receiver and stereo audio output.
$85 + Postage ∎ Complete Kit (SC6625)
siliconchip.com.au/Shop/20/6625
The circuit and assembly instructions were published in the January 2023 issue: siliconchip.au/Article/15616
siliconchip.com.au
Australia's electronics magazine
April 2023 77
|