This is only a preview of the September 2018 issue of Silicon Chip. You can view 53 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. Items relevant to "Dipole guitar/PA speaker without a box!":
Items relevant to "Digital white noise generator":
Items relevant to "Steam loco or diesel engine sound effects module":
Items relevant to "Super sound effects module – Part 2":
Items relevant to "El Cheapo modules Part 19 – Arduino NFC Shield":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
by
JOHN CLARKE
Relive the exciting days of steam-train travel with this Steam Train
Whistle or Diesel Horn sound generator. Use it in your model railway
layout, as a doorbell or just as a standalone sound effect. It can even
simulate the Doppler effect, providing a change in pitch as if the train
is passing by. And the Whistle/Horn sound can even be customised in a
number of ways, to suit your preferences.
S
cuit is that you can get steam train
team trains are always popular
sound without the corresponding
– many restored trains can be
sooty face!
seen travelling the counOur device simulates a steam-powtryside on the weekends. Their
ered whistle by mixing three separate
popularity is proven by the
oscillators with the output of a white
crowds of people gathering to
noise generator.
watch alongside the track and
These oscillators generate the whisthe number of people enjoying
tle chimes, with plenty of harmonics to
the ride.
ensure they have a rich sound, while
Along with the chuff-chuff
the noise generator provides the
sounds of the steam engine, it is
sound of the steam rushing out.
the whistle that gives the most
Features
You can adjust the rise time
excitement and nostalgia.
• Produces steam whistle or diesel horn sound effects
of the volume at the start of the
It is the toot of the whistle as
whistle. That simulates the rate at
the train departs; it is the sound • Steam simulation using white noise
which the cord is pulled to open
of the whistle as it passes you by • Adjustable volume rate rise for the steam whistle
the steam valve to the whistle.
and the blast of the whistle as the • Multiple trigger options
At the end of the whistle petrain enters a tunnel or approach- • Adjustable whistle time
• Optional Doppler Effect
riod, when the cord is released,
es a level crossing.
the valve quickly shuts itself off
The great thing about this cir- • Adjustable whistle frequencies
34
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
due to steam pressure (in our case, in
100ms).
If you elect to use Doppler Effect
simulation, the situation is somewhat
different. In this mode, the rise in volume simulates the train whistle starting from a distance away and then
increasing in volume as it approaches nearer.
The decay in volume after the train
passes (and after the frequency shifts)
simulates the decrease in volume as
the train moves away.
The Whistle/Horn sound can be
initiated with a manual pushbutton,
a microswitch, reed switch, relay or
by a signal from an external microcontroller.
New design
The last Steam Train Whistle published in SILICON CHIP was in July 1994
and used mainly op amps for the oscillators and an amplifier for the noise
source.
This new design includes many
more features, including Doppler Ef-
5-chime and 3-chime steam whistles and diesel horns
The steam whistle featured in this article has three oscillators controlled by the microcontroller. This is ideal for simulating the sound of 3-chime steam whistles for NSWGR
30 and 59 class steam locomotives. However, most other NSWGR steam locomotives
had 5-chime whistles, as did the locomotives in many other countries.
Clearly, we could have designed the circuit with five oscillators but that would have
a required a microcontroller with more pins and more passive components. But since
the simulated sound of this circuit is really quite convincing, we think this is a reasonable compromise.
If you want the exact whistle for a particular locomotive, it would better to use our
sound effects module (featured elsewhere in this issue) together with correct WAV stored
on its microSD card.
These comments also apply to diesel locomotive horns. Some large diesel locomotives
have five chime horns but many did have 3-chime or even 2-chime units.
fect, while using a much simpler circuit. That’s because it is instead based
around a low-cost microcontroller.
The basic concept is as follows. The
micro generates three different pulse
trains, each with a fixed duty cycle
and adjustable frequency.
These pulse trains contain various
frequencies including the fundamental and higher harmonics, which when
mixed together, make a whistle or horn
sound. When simulating a steam whistle, they are also mixed with white
noise, as explained above.
The mixed sound is then fed to an
audio amplifier with a built-in volume
control circuit. The volume control
signal comes from the same microcontroller which is producing the whistle/
horn sounds. The amplifier then drives
Fig.1: IC1 produces white noise which is used to emulate steam sounds, while IC2 produces three pulse trains which are mixed
together to give a whistle or horn sound. This signal is then fed to amplifier IC3 which drives the speaker. It is powered from a
5V DC or USB supply and the sound is triggered by onboard switch S1 or an external switch or signal via CON2.
siliconchip.com.au
Australia’s electronics magazine
September 2018 35
Specifications
• Power supply: 5V at 300mA from an external supply via screw terminals or USB cable
• Output power: about 1W into 8Ω
• Regular whistle period: 100ms to 22.5s, extended if S1 held down (no Doppler Effect)
2.5s to 22.5s, no extension (with Doppler Effect)
• Whistle volume rise time: 5ms to 8s
• Whistle volume fall time: 100ms fixed (no Doppler Effect
5ms to 8s (with Doppler Effect)
• Whistle frequency range: 244Hz to 1.053kHz
• Frequency adjustment steps: 3Hz at 250Hz, 6Hz at 333Hz,
12Hz at 500Hz, 24Hz at 666Hz, 48Hz at 1kHz
• Simulated speed for Doppler Effect: 80km/h
a speaker to produce the final sound.
The length of the Whistle/Horn
sound can be adjusted. If set to minimum, the whistle sound will only
be for as long as the trigger switch is
closed.
Or it can be set to a longer time so
that a brief press of the switch will
initiate the sound for a fixed period.
Depending on the mode, holding
the switch down may or may not extend the sound beyond this set period
Circuit description
The circuit is shown in Fig.2 and
comprises three ICs: two PIC12F617
microcontrollers (IC1 and IC2) and
a TDA7052A 1W Bridge-Tied-Load
(BTL) mono audio amplifier with DC
volume control (IC3).
IC1 is the white noise source and
runs an internal program that generates noise over the full audio spectrum.
You’ll find a full description of its operation in the “White Noise Generator”
project elsewhere in this issue.
It’s designed so that it can be re-used
in other circuits where a white noise
source may be required.
For now, all you need to know is that
a white noise “hissing” audio signal is
produced at its pin 7 output.
This noise signal is fed to the audio
mixing point, at the junction of the
10kΩ resistor and 100kΩ resistor, via
JP4, which can be used to disconnect
the white noise source when simulating a diesel horn or while adjusting the
oscillator frequencies.
IC2 produces the whistle and horn
sounds. It does this using three pulse
trains from its GP1, GP0 and GP5 digital outputs (pins 6, 7 and 2).
It also produces a DC control signal by filtering a PWM signal which
is produced at pin 5. This is fed to the
volume control input on amplifier IC3
and this is used as an “envelope” for
the whistle and horn sounds.
IC2 also monitors an external switch
via its GP3 input (pin 4, which is used
to trigger the sound effects. And it
reads the wiper position of trimpot
VR1 using its AN3 analog input (pin 3),
which controls various options such
as the component frequencies of the
whistle/horn sound, the whistle/horn
time and the volume rise rate for the
steam whistle.
The pulse trains from the GP1, GP0
and GP5 outputs are fed to an audio
mixing point, at the junction of the
100kΩ and 10kΩ resistors, via a 1kΩ
series resistor for each output.
The pulse trains from those three
outputs are not quite square waves; a
square wave has a duty cycle of 50%
while the pulses from these outputs
have a duty cycle of 43.75%.
This provides a richer set of harmonics than a square wave. A square wave
has only odd harmonics whereas this
series of slightly shorter pulses also
has even harmonics.
This produces a more realistic
sound.
The supersonic harmonics of the
mixed signal are filtered out by a 1nF
capacitor to ground and the audio signal is then AC-coupled to input pin 2
of audio amplifier IC3 via a 470nF capacitor. This drives the speaker connected to CON1 in bridge mode.
This chip has a volume control input on pin 4. A DC voltage is applied
to this pin and the higher the voltage,
the louder the output volume.
This volume control signal is produced by microcontroller IC2 using
filtered PWM, from its pin 5 PWM
output. The 4.7kΩ resistor and 100nF
capacitor form an RC low-pass filter
with a -3dB point of 339Hz.
The actual PWM frequency is
19.61kHz, which is so much higher
than the filter corner frequency that
the output of the filter is effectively a
DC voltage, proportional to the PWM
duty cycle.
Initially, the pin 5 output is low, setting the attenuation in IC3 to its maximum value of more than -70dB, which
mutes the audio output. The PWM
pulse width is gradually increased to
bring the average voltage at pin 4 up
to 1V, resulting in an eventual amplifier gain of +20dB.
The steam whistle/horn sound effect is triggered by pressing pushbutton S1 to pull the GP3 input (pin 4 of
IC1) low. It is normally held high by
a 10kΩ resistor to the 5V rail.
You can also use an external switch
Fig.2: use this PCB overlay diagram and matching photo as a guide for building the Steam Whistle / Diesel Horn board. IC3 and
CON3 are the only SMD components. Take care when soldering CON3 since the pins are small and close together, and easy to
bridge. Don’t get IC1 and IC2 mixed up; while they are the same type of chip, they are programmed with different firmware.
36
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
between pins 1 and 2 of CON2 (which
could be a set of relay contacts) or by
applying at least 1.5V between pins
2 and 3 of CON2, which switches on
NPN transistor Q1, pulling the GP3
input low.
The circuit is powered from 5V, either applied to part of terminal block
CON1 or via a micro type-B USB connector, CON3.
When using CON1, diode D1 provides reverse polarity protection. The
supply is bypassed using a 220µF capacitor and several 100nF capacitors,
one for each IC.
Changing the sound
Jumper shunts JP1-JP3 allow the
frequencies of these pulse trains to
be adjusted. Two of these jumpers are
inserted at a time, shorting two of the
pulse trains to ground and thus disabling them. This allows you to measure the frequency of the third pulse
train and make adjustments using VR1.
Pressing pushbutton S1 then saves the
new frequency setting to EEPROM.
Microcontroller IC2 detects whether any of the jumpers are inserted at
start-up by enabling internal pull-up
currents for the three output pins and
then sensing whether any of them are
held at ground potential.
If so, it goes into adjustment mode.
If none of the jumpers are present,
all three outputs will be high and the
software goes into the normal sound
effects generation mode.
A similar method is used to adjust
the initial volume ramp rate for the
horn/whistle. This is done by inserting
all three shunts, rotating VR1 and then
pressing S1 to store the new ramp time.
Trimpot VR1 connects across the
5V supply and so its wiper voltage
sweeps from 0V to 5V as its screw is
rotated clockwise.
This voltage is applied to the AN3
analog input of IC2 and converted to
a number using its internal analog-todigital convert (ADC). It is used to set
the pulse train frequencies and initial
volume ramp rate as described above
Parts list – Steam Whistle/Diesel Horn
1 double-sided PCB, coded 09106181, 79 x 48mm
2 2-way screw terminals with 5.08mm pin spacing (CON1)
1 3-way screw terminal with 5.08mm pin spacing (CON2)
1 8Ω 1W loudspeaker [eg, Jaycar AS3030 or AS3004, Altronics C0603C]
1 PCB-mounting micro type-B USB socket (CON3) [Altronics P1309, Jaycar PS0922]
2 8-pin DIL IC sockets (for IC1,IC2)
1 momentary pushbutton switch (S1) [Altronics S1120, Jaycar SP0600]
4 2-way headers with 2.54mm spacings with shorting blocks (JP1-JP4)
1 PC stake
Semiconductors
1 PIC12F617-I/P programmed with 0910618A.HEX (IC1)
1 PIC12F617-I/P programmed with 0910618M.HEX (IC2)
1 TDA7052AT/N2 1W BTL DC volume control amplifier (IC3) [Cat SC3551]
1 BC547 NPN transistor (Q1)
1 1N5819 1A schottky diode (D1)
1 3mm LED (LED1)
Capacitors
1 220µF 16V PC electrolytic
1 470nF 63V or 100V MKT polyester
5 100nF 63V or 100V MKT polyester
1 1nF 63V or 100V MKT polyester
Resistors (all 1%, 0.25W)
4 100kΩ
4 10kΩ
1 4.7kΩ
1 3.3kΩ
3 1kΩ
1 10kΩ mini horizontal trimpot, code 103 (3386F style) (VR1)
surrounding it.
You will need a fine-tipped soldering iron and 0.7mm diameter solder.
First, align the IC pins onto the pads
making sure the that chamfered side of
the chip is positioned towards the pin
1 indicator on the board, as shown in
Fig.2. Tack solder one of the outside
pins to its pad and check that the IC
alignment is correct. Re-melt the solder and realign if necessary. Then
solder the remaining pins. Make sure
you refresh the solder on the first pin
at the end.
If you accidentally bridge two pins,
the excess solder can be removed with
a dab of flux paste and some solder
wick.
The micro type-B USB connector is
soldered in a similar manner to IC3.
Align the leads to the pads and solder the two outer flanges on the sides
siliconchip.com.au
of the USB housing first, followed by
the five pins.
Clear any pins that are shorted with
solder wick.
The resistors should be fitted now
and these are colour coded, as shown
below. But you should use a digital
multimeter to check the values of each
resistor before soldering it as the colour codes can be mistaken.
Mount diode D1 next, with the
striped end (cathode) oriented as
shown in the overlay diagram.
We recommend using an IC socket
for ICs1&2. Take care with orientation
when installing the sockets – use Fig.2
as a guide.
Now fit headers for jumpers JP1JP4 and the PC stake at the GND position. Follow with the capacitors,
starting with the smaller MKTs and
then the 220µF electrolytic capacitor.
Resistor Colour Codes
Construction
The Steam Train Whistle is built on
a double-sided PCB coded 09106181,
measuring 79 x 48mm. It can be housed
in a UB3 plastic utility box if desired.
The overlay diagram, Fig.2, shows
where the parts are fitted. Install SMD
IC3 first as it is easier to solder the
pins when there are no components
1 100Ω
No. Value
4 100kΩ
4 10kΩ
1 4.7kΩ
1 3.3kΩ
3 1kΩ
1 100Ω
4-Band Code (1%)
brown black yellow brown
brown black orange brown
yellow violet red brown
orange orange red brown
brown black red brown
brown black brown brown
Australia’s electronics magazine
5-Band Code (1%)
brown black black orange brown
brown black black red brown
yellow violet black brown brown
orange orange black brown brown
brown black black brown brown
brown black black black brown
September 2018 37
Changing the whistle or horn sound
Changing the whistle period
With no jumpers inserted for JP1-JP3,
rotate VR1 to adjust the whistle period, up
to a maximum of 22.5s (fully clockwise).
If you are not using the simulated Doppler Effect, the whistle period can be extended indefinitely by holding down S1.
Changing the volume rise rate
and Doppler effect
This applies to the steam whistle
sound only (ie, not the diesel horn).
Switch off power and insert jumper
shunts for JP1, JP2 and JP3. Power up
and set VR1 for the desired ramp time,
with a more clockwise position selecting
a longer ramp.
To disable the Doppler Effect, set VR1
to a position between fully anti-clockwise
and halfway.
With VR1 fully anti-clockwise, the initial volume ramp-up is almost instant,
while if you set it just slightly less than its
midpoint, you will get a ramp-up time of
around eight seconds. Intermediate settings give a shorter ramp-up time.
To enable the Doppler Effect, set VR1
to a position between halfway and fully
clockwise. The ramp setting is similar, ie,
just above halfway will give you an almost
instantaneous ramp-up while setting VR1
fully clockwise sets the ramp-up time to
around eight seconds.
In this mode, there is also a volume
ramp-down period at the end of the effect
and it is the same time as the ramp-up.
When VR1 is set at the required position, press S1 so that the setting is stored
in flash memory.
Switch off power and remove the
three jumper shunts. Set VR1 back to
the required position for the whistle period when you’ve finished. You can then
power it back up and press S1 to test
the new setting.
Note that it’s generally a good idea to
set the whistle period in Doppler Mode to
be slightly longer than twice the ramp-up/
ramp-down time. This way, the volume
will rise to maximum and then almost
immediately begin to fall again, as if the
Sound effect
train has just passed.
You may need to tweak the volume
rate and whistle period a few times to
get the desired effect.
Changing the oscillator
frequencies
The table below shows some suggested sets of oscillator frequencies to
simulate a steam whistle and various
diesel horns but note that you are not restricted to just using these frequencies.
The first entry shown gives the frequencies that the unit will default to the
first time it is powered up.
The oscillator frequencies are changed
one at a time. Start by switching off power and then place two jumper shunts on
JP1-JP3, leaving out the jumper in the
channel that you want to adjust. Remove JP4 to disable steam noise for
the moment.
Now attach a frequency meter (eg,
a DMM with frequency measurement)
to the right-most pin on the unused
jumper header.
Connect its ground reference to
the ground PC stake (between S1 and
CON2).
Apply power and adjust VR1 until your
meter reads the frequency required. It
can be adjusted over the range of 2441053Hz. The frequency will change in
steps of 3Hz at the low end, rising to
48Hz at the high end.
You will be able to hear the oscillator if the speaker is connected. When
you have settled on the required frequency, press S1 to store the value in
flash memory.
To adjust another oscillator, disconnect power and move one of the jumper shunts, then re-apply power and go
through the same procedure again.
When you have finished, switch off
and remove JP1-JP3. Re-install JP4 if
you removed it earlier.
Set VR1 back to the required position for the whistle period now that you
have finished adjusting the oscillator
frequencies.
Oscillator 1 Oscillator 2 Oscillator 3
White noise
Steam whistle (default)
740Hz
525Hz
420Hz
Yes (JP4 in)
2-Car Diesel
600Hz
520Hz
420Hz
No (JP4 out)
40-43, 4401-4440 Diesel
277Hz
329Hz
440Hz
No (JP4 out)
422, 442, 73, 48126 Diesel
548Hz
322Hz
429Hz
No (JP4 out)
Suggested oscillator frequencies for various whistles or horns.
38
Silicon Chip
Australia’s electronics magazine
This capacitor is polarised and must
be installed with the polarity shown,
with the longer lead through the hole
marked “+” (the striped side is negative).
Install transistor Q1, switch S1 and
trimpot VR1. Then you can mount terminal blocks CON1 and CON2. CON1
comprises two dovetailed 2-way screw
connectors and CON2 is a 3-way screw
connector.
Ensure that all the terminal blocks
are fitted with the wire entry holes to
the outside edge of the PCB.
Finally, LED1 can be soldered in
place. We mounted it with the plastic lens 15mm above the PCB so that
it would protrude through the lid of
the UB3 Jiffy box but you could mount
it at a different height if necessary. Fit
it with the longer anode lead soldered
to the pad marked “A” on the PCB.
Although shown as a bare board, the
Steam Train Whistle can be installed
in a UB3 box. The PCB clips it into
the moulded side rails on the inside
of the box.
Cutouts can then be made in the
ends of the box for the USB connector
and the wires going to screw terminals
CON1 and CON2. The loudspeaker is
ideally mounted in a small box so that
it has a good bass response.
Testing
With IC1 and IC2 out of their sockets, apply power either via a 5V DC
supply connected to CON1, or using
a USB cable from a computer or USB
supply.
Check that LED1 lights up and that
there is around 5V between pins 1
and 8 of the sockets for IC1 and IC2.
If power is applied to CON1, the reading will probably be closer to 4.7V due
to diode D1.
Regardless, you should get a reading between 4.5V and 5.25V. You can
then remove power from the circuit.
If you have purchased pre-programmed microcontrollers then you
can plug IC1 and IC2 into their sockets now, making sure that they are
oriented correctly and that the correct programmed IC is in the correct
socket. The chip programmed as the
noise generator is IC1.
If your chips have not already been
programmed, you will need to program
them first, using HEX files downloaded
from the SILICON CHIP website.
There are two different files for IC1
and IC2.
siliconchip.com.au
Connect the speaker to CON1 and
apply power again. Set VR1 fully anticlockwise and press and hold S1. You
should be greeted by the steam train
whistle sound.
If you don’t hear the steam noise
in the background, check that JP4 has
been inserted.
Installation
The board is too large to mount inside a locomotive so if you want to
use it as part of a model
railway layout, the best
place to put it would be
underneath the layout,
for example, near a station.
You could then mount the speaker
inside the station. It could be triggered
manually or via a reed switch or microswitch as the train passes.
Whatever kind of switch you are
using, connect it between pins 1 and
2 of CON2.
Or if you are using a microcontroller
to trigger it, connect a digital output
pin on that micro to pin 3 of CON2
with the micro’s ground going to pin 2.
You can apply anywhere between 1.5V
and 12V to this pin to trigger the unit.
Assuming you’re building
this for a model train
layout, the PCB can be
mounted “as-is” wherever
there is a suitable place
on or in your layout. But
it is also designed to clip
into the side rails of a
UB3 Jiffy box, as shown
here, with the LED just
poking through the front panel.
Naturally, access holes will need to be
drilled in the ends of the box to allow for power
and speaker wiring, along with the external trigger switch.
The Doppler Effect
The Doppler Effect refers to the fact
that when an object is moving towards
you, any sound that it generates will appear to be higher in pitch than usual. And
similarly, if that object is moving away
from you, the sound will appear to be
lower in pitch. For example, it is very obvious when a vehicle with a siren passes
you at high speed.
It happens because sound waves
travel through the air at approximately
340m/s (1200km/h) and as the speed
of the generating object (relative to you)
becomes a significant fraction of that,
the sound waves pass you at a noticeably different rate, thus altering the perceived pitch.
If you are interested in finding out
more about the Doppler Effect, see
https://en.wikipedia.org/wiki/Doppler_effect
Since trains can travel quite fast, the
Doppler Effect can be very apparent, especially when they use their whistle or
horn as they are passing you. At 80km/h,
the pitch changes by about 6.5% in each
direction and the overall 13% difference
is very noticeable. So we have included
a facility to simulate this.
SC
It’s time to TRI us!
DESIGNER’S KITS
Coilcra Designer’s Kits for all RF, Power, Filter and Data applications
Coilcra Designer’s Kits made for both Surface Mount Devices and ruHole Devices.
To simplify your prototyping, low cost Designer’s Kits are available for many of the Coilcra range of products.
Each Kit has an assortment of standard values along with detailed product speci�cations.
Makes research and designing very easy in your workshop.
FREE re�lls when parts have been used from the kit.
Quantity discounts apply: 10% off any combination of 3 or more, 20% off any combination of 5 or more and
30% off any combination of 7 or more, when purchased
Our Points of Difference
FREE SAMPLES
We are a supplier that keeps FREE samples on site in our Melbourne warehouse for immediate issue. Other suppliers
in Australia/NZ do not offer free samples at all, let alone so quickly.
PRICE
We beat online pricing and account holders will be invoiced and therefore no need to pay upfront when ordering.
COD also available on request. Purchasing through the official Australian representative eliminates the additional
costs of duties and expensive overseas freights.
LOCAL SUPPORT
Our Engineers have over 50+ years of experience, offering supportive expert advice.
We have knowledgeable and friendly staff within all aspects of the business, that provide fast and reliable support.
TRI COMPONENTS –-- Authorised COILCRAFT Australian Distributor
siliconchip.com.au
Australia’s electronics magazine
TRI
COMPONENTS
PTY LTD
1/32 Miles Street,
Mulgrave Vic 3170
Contact: Christopher Dawson
(+61 3) 9560 2112
www.tricomponents.com.au
tricom<at>tricomponents.com.au
September 2018 39
|