This is only a preview of the August 2013 issue of Silicon Chip. You can view 24 of the 104 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. Items relevant to "PC Birdies: Bird Song Without The Mess":
Items relevant to "Build An iPod Charger Adaptor":
Items relevant to "Active RF Detector Probe For DMMs":
Items relevant to "1.5kW Induction Motor Speed Controller Revisions":
Purchase a printed copy of this issue for $10.00. |
Bird song –
without the mess!
PCBirdies
Ever wished you could have beautiful bird song in your home,
without having to own a live caged bird? With PCBirdies, you can have
the luxury of not one, but two singing birds. You won’t have to buy a
cage or even bird seed. . . and best of all, there’s no mess to clean up!
I
PCBirdies is powered from a 3V hours or days without singing at all.
t can be very calming and relaxing
to have bird song in your home. In lithium button cell and employs two PCBirdies, on the other hand, can be
fact, when people have heard this microcontrollers, each one driving its guaranteed to sing for your pleasure
many times during the day, at seemproject, without knowing the techni- own piezo transducer.
Arguably PCBirdies sounds similar ingly random intervals.
calities, they have found it charming.
Canary songs consist of a
PCBirdies will sing from time
series of chirps, tweets, trills
to time, at random intervals so it
and warbles and they seldom
(they?) can pipe up unexpectedly Power: 3V from a CR2032 lithium cell
repeat the same sequence twice.
at any time during the day, which
PCBirdies’ songs also consists of
can be a pleasant diversion. You Current: 0µA when switched off,
1.8µA per IC during periods of silence
chirps, tweets, trills and warbles
can hear a few samples of its song
735µA per IC while chirping
but its songs are much shorter,
on our website.
typically lasting for about eight
PCBirdies is (are?) housed in Sounds: Selection 1 – typical canary sound
seconds.
a small plastic box. This might
Selection 2 – Fife Canary
PCBirdies gives the option to
sound a bit cruel but it is entirely
Selection 3 – various individual phrases
change the canary sound from
happy to be there and we can asSelection 4 – medley of the first three.
one type to another. (Try doing
sure concerned readers that no
that with a real bird). Each sebirds were harmed or put under
stress during the development of this to a canary but it we should state at the lection imitates typical canary sound
project. In fact, as the proverb states, outset that a typical canary’s song is phrases. Song A is a typical canary and
“A bird in the hand is worth two in more varied and they typically sing for Song B simulates a Fife canary. Song
much longer periods (their songs can C is a selection that comprises varithe bush”.
ous single phrases of these birds. The
Inside the box are two piezo trans- last up to several minutes at a time).
But then again, they may go for fourth selection comprises a medley of
ducers that produce sounds which
all the above played over time.
simulate those of two separate birds.
PCBirdies sings at random. Each
So it might be said that PCBirdies is
By JOHN CLARKE
song is repeated between two and
better than two in the hand.
Specifications
28 Silicon Chip
siliconchip.com.au
a short interval. This has been done
to avoid any clicks from the piezo
transducers which would otherwise
spoil the effect.
Circuit details
Fig.1 shows the circuit and it is
quite simple, comprising two identical
microcontrollers with both using same
software; one microcontroller acts as
master and the other behaves as the
slave. Power comes from a single 3V
lithium button cell.
IC1 is the master microcontroller
and this has an LDR connected between its GP2 and GP5 inputs, to
monitor the ambient light. To do
this, the GP5 output, pin 5, goes low
momentarily to connect the LDR and
470kΩ resistor in series between the
+3V supply and 0V, via GP5.
When light is present, the LDR has
a low resistance and so the GP2 input
will be low; close to 0V. In darkness,
the LDR’s resistance is high and GP2
will be high; close to +3V. The voltage
level at GP2 is duplicated at the GP4
output which connects to the GP2
input of IC2. So when IC1 “sings”, so
does IC2.
But the GP4 output of IC1 is used
more effectively than just following
the LDR light level measurement. By
taking advantage of the fact that the
bird sound is not produced in darkness, the GP4 output of IC1 is also used
to help IC2 resynchronise with IC1.
During longer phases of no output
sound from IC1, the GP4 output is
taken high. This sets IC2 to sense darkness and its timer that determines the
gaps between bird songs is reset.
PCBirdies is fully selfcontained in a small zippy box. It will
only burst into song in daylight – at night,
like any good canary, he (it? they?) goes sound asleep!
27 times with a 2.4 to 17-second gap
between them. There is an extended
gap between each series of repeated
songs and this is between 80 seconds
and 9 minutes.
PCBirdies only sings during daylight or under artificial light - an LDR
(light dependent resistor) senses the
ambient light level.
The “birds” sing in and out of unison to simulate two separate birds.
The two birds are re-synchronised at
the end of a darkness period and also
at the end of the extended gap period.
Note that PCBirdies does not simply
play sampled segments of real canary
songs. Rather it simulates the bird song
by varying the frequency, volume and
length of bursts of pulse trains applied
to the piezo.
The volume is adjusted by changing
the pulse width of signals applied to
the piezo transducers. Narrow pulses
give low volume while wider pulses
give more volume. Maximum pulse
width equates to a pulse duty cycle
of 50%.
Each chirp starts with a minimum
pulse width, increasing to the required
volume level over time. Similarly
when a chirp or tweet is about to end,
the pulse width is reduced to zero over
S3 POWER
K
1mF
10k
470k
10k
MMC
3V
LITHIUM
BATTERY
D1
1N4004
A
1
Vdd
4
MCLR/
GP3
5
GP4
3
5
GP2
2
GP5
GP0
Vss
A
SC
Ó2013
PIEZO
1
7
2.2k
2
GP5
GP0
Vss
PIEZO
2
7
2.2k
8
S1
S2
K
'PC BIRDIES'
siliconchip.com.au
3
6
IC2
PIC12F675 GP1
8
1N4004
GP4
GP2
6
IC1
PIC12F675 GP1
LDR1 l
1
Vdd
4
MCLR/
GP3
Fig.1: not much to it, is there! Basically, it’s two microprocessors driving two
piezo transducers. The bird songs can be altered by pressing S1 and/or S2.
August 2013 29
LDR1
10k
IC2 PIC
12F675
S1
1
2.2k
PIEZO 1
10k
CR2032
BUTTON CELL
HOLDER
PIEZO 2
PIEZO
TRANSDUCER
1
SEIDRIB CP
2.2k
4004
470k
13140180
PCBirdies
2
1mF MMC
D1
+
PIEZO
TRANSDUCER
IC1 PIC
12F675
1
S3
S2
C 2013
Fig.2: the component overlay for the PCB with a matching photo alongside. The piezo transducers are secured to the PCB,
as described in the text, and the whole assembly pops into a UB5 box.
As soon as IC1’s gap timer ends,
ready to play another bird song, it
sets the GP4 output low and so IC2
is now also ready to begin singing.
Random delay periods added between
the GP4 output going low and the IC2
bird singing give the effect of the two
birds singing together, sometimes but
not always in synchronisation.
Each microcontroller drives its
piezo transducer from the GP0 and
GP1 outs, pins 6 & 7 with out-of-phase
3V signals; ie, when GP0 is high, GP1
is low and when GP0 is low, GP1 is
high. This results in a 6V peak-to-peak
drive signal to each piezo.
The 2.2kΩ resistor from the GP0 output is included for two reasons. One
is to provide high frequency rolloff
for the piezo signal, removing upper
frequencies from the square wave
drive. The rolloff is due to the 50nF
capacitance of the piezo transducer
combined with the series 2.2kΩ resis-
tor; the result is a low pass RC filter.
The 2.2kΩ resistor also prevents
GP0 from being shorted to 0V when
the switch (S1 for IC1 and S2 for IC2)
is pressed. Normally, GP0 is set as an
output but at power up, GP0 is set as
an input with an internal pullup holding this input high unless the switch
is pressed.
Pressing the switch causes the
microcontroller to change to the next
bird sound available. This selection is
stored in EEPROM so that the setting
remains whether power is off or on.
Saving power
While PCBirdies is switched on,
the current drain is 1.8uA per microcontroller during silence and 735µA
per microcontroller while singing.
Maximum current drain when both
birds are singing is about 1.5mA. With
the birds singing intermittently (as
they do) we expect that you should
get about 100 days of continuous use
before the cell requires changing.
At around $2 to $3 per cell, that’s a
lot cheaper than bird seed!
Both microcontrollers utilise a
watchdog timer which is repeatedly
cleared during normal program running to prevent it from timing out and
resetting the micro.
Typically the watchdog timer will
time out after 2.3 seconds. During the
gap period when there is no sound
produced, the micro is in sleep mode
and is woken up every 2.3 seconds by
the watchdog timer (perhaps its barking wakens the napping PCBirdies?)
The number of watchdog timer
timeouts that occur is counted to set
the gap timer period. The gap timer is
reset to zero with the LDR in darkness
for IC1 and with GP2 high for IC2.
As already noted, power for the
circuit comes from a 3V button lithium cell, type CR2032. Diode D1 is
These waveforms demonstrate how the microcontroller drives the piezoelectric transducer in push-pull. In the left screen
shot, the yellow trace is the output at pin 6 while the green trace is the signal at pin 7. The mauve trace at bottom is the
difference between the two signals which is applied to the transducer. The resulting waveform is equal to the sum of the
two waveforms (in theory) but in practice it is less. The waveforms at right were taken for the same connections as in the
scope screen at left but the note is less than half the frequency and the duty cycle is also much reduced.
30 Silicon Chip
siliconchip.com.au
C
L
9.0mm
6.5mm DIAMETER
PIEZO 2
PIEZO 1
1
SEIDRIB CP
4004
13140180
PCBirdies
1
+
included to provide reverse polarity
protection. Normally this should not
happen as the cell will only make an
electrical connection to the cell holder
if it is correctly inserted.
However, it is not unknown for some
constructors to solder cell holders in
the wrong way.
If that happens and a cell is inserted,
the diode will conduct to protect
the two microcontrollers but unless
the cell is quickly
removed (upon the
awful realisation that
it is in the wrong way)
it will get hot and be
quickly discharged.
The lithium cell is
bypassed with a 1µF
capacitor. Each micro
has its MCLR connected to the +3V supALL 4mm DIAMETER
ply via a 10kΩ resistor.
This provides a poweron reset each time
power is first applied.
ALL 4mm DIAMETER
C 2013
Construction
S3
1
2
ZO
PIE
ZO
BATTERY HOLDER
PCB (SNAPS INTO GUIDES ON SIDE OF BOX)
Fig.3: this diagram shows not only how it all goes together in the box but also
the positions for the switch hole (S3) and the sound holes in each end. You’ll
also need a hole in the case lid above the LDR (circled in red) if you don’t use a
translucent case.
These waveforms show the songs being “sung”
simultaneously by the two microcontrollers, with the
connections being at pin 7 in each case. Note that the songs
are not synchronised even though they start out in sync at
switch-on.
siliconchip.com.au
PIE
All components (including the battery and piezo transducers) for PCBirdies mount on a single PCB coded
08104131 and measuring 62 x 48mm.
It is housed in a translucent blue UB5
box that measures 83 x 54 x 31mm.
No screws or mounting posts are
used – the completed PCB drops into
the moulded rails on the side of the
box, with the power switch emerging
through the side.
A label measuring 78 x 49mm affixes
to the lid of the box.
Taken at a faster sweep speed, these waveforms show
how the beginning and the end of each pulse train has a
much reduced duty cycle to avoid any tendency for the
piezoelectric transducers to produce audible clicks, which
would rather detract from the canary’s song!
August 2013 31
Once the PCB is built and tested it is inserted in the box.
The idea is to “slide” it in so that the power switch (S3)
emerges through its hole in the box then the back of the
board is pushed down so that it clicks into place in the
mouldings on the case.
Parts List
– PCBirdies
1 PCB coded 08104131, 62 x 48mm
1 translucent blue UB5 box 83 x 54 x
31mm (see text)
1 PCB mount SPDT toggle switch
(S1) (Altronics S1421 or equivalent)
2 2-pin momentary pushbutton PCB
mount switches (Jaycar SP0611)
2 DIL8 IC sockets
1 PCB mount 20mm cell holder (Altronics S5056, Jaycar PH9238)
1 CR2032 lithium cell
2 piezo transducers (Altronics S6140,
Jaycar AB3440)
1 LDR (Jaycar RD3480, Altronics
Z1619) (LDR1)
Tinned copper wire
Semiconductors
2 PIC12F675-I/P microcontrollers
programmed with 0810413A.hex
(IC1,IC2)
1 1N4004 1A diode (D1)
Capacitors
1 1µF monotlithic multilayer ceramic
(MMC)
Resistors (0.25W, 1% or 5%)
1 470kΩ
(4-band code: yellow purple yellow brown)
2 10kΩ
(4-band code: brown black orange brown)
2 2.2kΩ
(4-band code: red red red brown)
32 Silicon Chip
Here’s what it looks like assembled inside the box.
Everything is on the one PCB. If you have used anything
but the translucent blue box, you’ll need to drill a hole in
the box lid so that the LDR (top, left of board) can “see”
daylight. Otherwise PCBirdies will never turn on!
Before installing the parts, check
the PCB for any faults. Repair these
as necessary. If you are building from
a kit or using the PCB supplied from
the SILICON CHIP shop, you will find
that these PCBs are of excellent quality and so will not normally require
any repairs.
Follow Fig.2 for the PCB component
assembly.
Install the resistors and diode first.
The resistors are colour coded with the
resistance value. There are only three
values of resistor; their colour codes
are shown in the parts list. A digital
multimeter should also be used to
check the resistance values.
Make sure the diode is installed
with the correct polarity with the
striped end oriented as shown in the
overlay diagram.
The capacitor can be installed
next, along with the two push button
switches and the IC sockets. Make sure
the IC sockets are oriented correctly.
Power switch S3 is mounted harddown on the PCB and its main body
terminal is soldered to the PCB before
the remaining three switch pins are
soldered.
The 20mm button cell holder can
be installed taking care to orient this
as shown.
If you are using a translucent case,
then the LDR can be mounted at about
5mm above the PCB. That way the LDR
will receive light through the box sides
(even if a panel label is attached to the
lid). If a grey or black case is used, the
the LDR top face needs to be 14.5mm
above the top of the PCB so that it can
be inserted into a hole drilled in the
lid of the case.
Insert the 3V cell into its holder
and check that there is a 3V supply
between pins 8 and 1 of each IC socket
when switch S3 is turned on. If this is
correct, turn the power switch off and
mount the ICs.
The piezo transducers are mounted
at about a 45° angle on the side of the
PCB, sitting within the cut outs. Fig.3
shows the arrangement. We soldered
the transducer wires directly into the
signal output pads after first looping
the wires through the two holes that
provide for stress relief.
The piezo transducers have two
flanges for mounting and we looped
some tinned copper wire through the
flanges and soldered these to the pads
on the PCB. This keeps the transducers
in position with one flange on the top
side of the PCB and the other flange
on the bottom of the PCB.
The PCB is designed to clip into the
integral side rails of the box. A 5mm
hole is required in the side of the box
for switch S3. The diagram shows
where the hole should be.
If you must use a grey or black case,
drill a suitable hole for the LDR in the
lid, immediately above where the LDR
is mounted.
An array of holes is also required
in the ends of the box. Use the photos
and diagrams for the positioning of
the holes and drill these out to 4mm
in diameter.
The front panel can be downloaded
siliconchip.com.au
Before placing the PCB in the box, you’ll need to carefully
drill sound holes in each end. If you don’t do this there
will be two very muffled canaries! The exact positions
are not important but you should aim to make the pattern
symmetrical about the centre so it looks good!
from the SILICON CHIP website (www.
siliconchip.com.au/shop and then
select “Panel artwork”). It’s a free
download for subscribers (print or
online) but there is a nominal charge
for non-subscribers.
Print the label onto good quality
thick paper – photo paper is ideal. It
can be secured to the lid with a suitable glue or Silicone. The hole for the
LDR (required in a solid coloured box
only) can be cut out with a sharp craft
knife or leather punch.
Changing the songs
When PCBirdies is first turned on,
the bird sound produced by both IC1
and IC2 are of the Fife Canary. Changing the bird sound produced by IC1
is done by pressing S1 during power
up. Similarly, changing the bird sound
If you don’t get any sound from PCBirdies after final
assembly (and it worked before you put the PCB in the box,
make sure that the CR-2032 button cell is right down in its
holder. Push it down so that it clicks into place to ensure
reliable contact.
produced by IC2 is done by pressing
S2 during power up.
Power up involves switching off
S3 for a few seconds then switching
it on again.
The pressed switch (S1 and/or S2) is
released after five seconds from power
up. You can either press S1 on its own,
S2 on its own or both switches during
power up to change the song(s).
If just S1 is pressed and held during
power up, then only the song produced
by IC1 will change; similarly if just
S2 is pressed, it’s only the song produced by IC2 that changes. With both
switches pressed, songs from both IC1
and IC2 will change.
There are four bird song selections.
The Fife Canary bird song is the first
that is set in the program. The next selection is a different canary bird song.
The third and fourth selections are
medleys of the bird songs. The third
selection provides just a few of the
more distinctive phrases used within
the Fife and second canary songs.
These are played at random.
The fourth selection provides a
medley of both the full Fife Canary
repertoire, the full second canary song
repertoire plus the phrases available
from the third selection. These are all
played at random.
You will return to the original Fife
Canary sound with the next selection
accessed by S1 and S2 at power up.
If you want to have both IC1 and IC2
play the same repertoire, then press
just one of the switches (S1 or S2) as
many times as necessary during power
up until that IC plays the same song
as the other.
SC
Full range of PICAXE products in stock now!
PICAXE Chips, Starter Packs, Project Boards, Experimenter Kits,
Books, Software and Accessories.
PICAXE 2x16 and 4x20 OLED Displays
OLED displays provide much brighter
displays, better viewing angles and lower
current consumption making them a
great alternative to LCD’s.
PICAXE Starter Packs available for
08M2, 14M2, 18M2, 20M2, 28X2 and
40X2 Microprocessors.
This module allows PICAXE projects to
display (yellow on black) text interfacing
via one single serial line or I²C bus.
PICAXE-18M2 chip is provided
pre-programmed with the
open-source AXE133 firmware.
For pricing and to shop online, visit www.wiltronics.com.au
Ph: (03) 5334 2513 | Email: sales<at>wiltronics.com.au
siliconchip.com.au
August 2013 33
|