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. |
WHITE NOISE
GENERATOR
This white noise generator is very simple and cheap to build and
produces white noise which does not repeat over any short time frame. It
has a variety of uses, as explained below.
A
white noise signal has equal intensity at all frequencies in the
band of interest; for example,
20Hz-20kHz for audio. It’s the hissing sound that you hear if you tune
an analog FM radio to a frequency on
which there is no transmission.
There are many reasons why you
may want a white noise signal. For
example, you can use white noise to
drown out external noises that may
interfere with your sleep. If that dripping tap is keeping you awake, don’t
count sheep; try a low-volume white
noise source with a speaker close to
your bed.
We can attest: it works wonders!
It’s especially effective at helping
babies get to sleep since they are used
to hearing somewhat similar sounds
in the womb. It can also be used to
help treat (or at least mask) tinnitus (a
persistent ringing sound heard in the
ears when there is no sound present).
White noise sources can be used to
measure the bandwidth or impulse response of a circuit and to check room
acoustics or optimise a PA system.
They are also used in analog audio
synthesisers to help produce the “ssshhhh” sound of various percussion instruments such as hi-hats, snare drums
and cymbals.
Generating white noise
There are several ways to generate white noise. For example, if you
reverse-bias a zener diode or transistor emitter-base junction (ie, the baseemitter reversed) with a low DC current level, an AC voltage will appear
across it and this will have a white
noise characteristic.
32
Silicon Chip
This IC is not available any more
but with modern components, we
can make an even better digital noise
source.
An even better
white noise source
Fig.1: the “circuit” could hardly be
simpler because everything is done
in software within the PIC12F617-I/P.
Noise output is taken from pin 7, while
a 100nF capacitor bypasses the supply
(pins 1 and 8) – pins 2, 3, 5 and 6 are
not connected.
But the resulting AC voltage level
is quite low and typically needs to be
amplified by a factor of several hundred times to make it usable.
Alternatively, white noise can be
generated digitally with a pseudo-random number generator.
This has the advantage that the signal level is already high, it is consistent and it is not dependent on a
particular transistor or zener diode’s
characteristics.
National Semiconductor used to sell
a digital noise source IC, the MM5837
(designed in the 1970s) that used an internal 17-bit pseudo-random sequence
generator to produce white noise for audio applications. Supplied in an 8-pin
DIL package, it was designed for musical instruments, synthesisers and for
room acoustics testing.
Its main disadvantage was a noticeable cyclic repetition. The repetition
was due to the full random sequence
being produced in less than one second and being continuously cycled.
by John Clarke
Australia’s electronics magazine
Our design uses a low-cost 8-bit
PIC12 microcontroller to produce a 31bit pseudo-random sequence, which
only repeats after 231 or approximately
two billion cycles. That works out to
nearly eight hours so the repetition is
definitely not discernible.
The basic “circuit” for our white
noise generator is shown in Fig.1. IC1
is a PIC12F617-I/P which has a 2-5V
supply fed into pins 1 and 8. A 100nF
bypass capacitor is connected directly
between pins 1 and 8 to ensure that
it has a stable operating voltage. The
noise output appears at its GP0 digital
output (pin 7).
Pin 4 is the master clear/reset
(MCLR) pin. This is held at VDD during
normal operation by an internal pullup current. If it is externally pulled
low, this will hold the microcontroller
in a reset state and so the noise output
at pin 7 will cease. When released,
the internal pull-up will bring it high
again, allowing the processor to run
and resuming noise generation.
You just need the two components,
the programmed IC and a 100nF bypass capacitor, as shown in Fig.1.
And it’s dead easy to wire up since
only four pins are normally used – the
bypass capacitor can be soldered right
next to the IC (even right across pins
1 and 8 if you wish!). The other four
pins (pins 2, 3, 5 and 6) are not used
and should be left disconnected.
siliconchip.com.au
While we are
The noise frequency
showing this as
distribution is therea mini “project”
fore even up to about
in its own right
76.923kHz, which is
for those who
the Nyquist limit for
need a dead simthis signal; ie, half
ple white noise
the sampling rate.
source, it will
Because the outbe quite familiar
put is a square wave,
when you read Fig.2: here’s what happens inside the PIC – the 28th and 31st bits are XOR-ed
it will have compoand fed back into the first bit while the other 31 are shifted to the right by one.
the next project
nents at higher frethis month, the
quencies than this
Steam Train Whistle project, because into Q1, so you can think of this as a but they will have a decreased amplithis is exactly what we used for the modified type of “bit rotate” operation. tude and power level.
“steam” component.
The measured spectrum from our
The Q31 bit value also determines
the level on pin 7 and thus becomes prototype is shown in Fig.3. It extends
Pseudo-random
the noise output; hence we do not want over the entire audio spectrum (20Hzsequence generation
to retain its value in one of the other 20kHz) and well beyond at both the
Fig.2 shows how the software genera- bits; if we did, this would quickly lead low-frequency and high-frequency
tors a pseudo-random sequence genera- to repetition.
ends (the measurement bandwidth is
tor using three 8-bit shift registers and a
This approach has two advantages. only 20kHz).
7-bit shift register. The bits within the One, the 31-bit length leads to a very
While the IC generates white noise,
four shift registers labelled Q1 to Q31. long time until the sequence repeats it could potentially be used to generate
These bits are pre-loaded with a spe- and two, the simple XOR gate used to pink noise with an appropriate filter at
cific value when the micro comes out provide the pseudo-random effect is its output. But such a filter is not simof reset, to provide a starting point for very easy to implement in software and
ple to design; it is something that we
the random sequence; as explained be- takes very little time to process, allow- will cover in a future article.
low, this can be any state but all zeros. ing for a high clock rate and thus givPink noise has its own uses, such as
Each time a clock pulse occurs, the ing the noise signal a wide bandwidth. for calibrating audio equipment, simuvalue of Q1 is moved into Q2, Q2 into
The entire process to update the con- lating background noise and can also
Q3 and so on, up to Q30 which is moved tents of the four registers, including help with sleeping.
into Q31. This means that all the bit the XOR operation, takes 13 software
Ensuring a long
values are updated from their neigh- instructions.
bour, except for Q1.
The internal 8MHz oscillator of the repetition time
It gets its value instead from the out- PIC12 gives a 2MHz instruction rate (it
You may be wondering how we know
put of a two-input exclusive-OR (XOR) takes four cycles to execute one instruc- that the sequence generated by this argate, with its inputs being the values of tion) and this results in a sampling rate rangement won’t repeat for 231 cycles.
bits Q28 and Q31.
That is guaranteed by using the corof 153.846kHz (2MHz÷13).
Once this shifting is complete, the
When divided into the cycle length, rect “taps” (in this case, bits 28 and 31)
value of Q31 is effectively lost, al- this gives us the approximately eight- to be combined to generate the new
though it does control the value loaded
hour repeat rate mentioned earlier. value of Q1 for each cycle.
The list of taps required for various
length shift registers to ensure a maximum length repeat cycle is given on
page 5 of the following application note:
www.siliconchip.com.au/link/aakr
Note that this document refers to the
use of an XNOR (exclusive NOR) gate
rather than XOR gate. The only difference is with the lock-up state. That is
the initial state of the shift registers
where the generator stops producing a
varying output.
The XNOR version has a lock-up
state when all values in the shift registers are ones (high output), whereas
the XOR has a lock-up state of all zeroes (all low).
The lock-up situation is prevented
from happening when using either
XOR or XNOR gates by starting the
Fig.3: the spectrum of the white noise generated by the PIC. The power level is
noise sequence with a number other
consistent across all frequencies up to about 20kHz. The drop in level discontinuity
than all zeroes or all ones.
at 20kHz is due to sound card and computer software limitations.
SC
siliconchip.com.au
Australia’s electronics magazine
September 2018 33
|