This is only a preview of the June 2009 issue of Silicon Chip. You can view 31 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 "High-Current, High-Voltage Battery Capacity Meter, Pt.1":
Items relevant to "GPS Driver Module For The 6-Digit Clock, Pt.2":
Articles in this series:
Items relevant to "Build A Beam-Break Flash Trigger":
Items relevant to "PICAXE Humidity Measuring Using The HopeRF HH10D":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
Digital
Audio
Oscillator
Design By DARIAN LOVETT
Words by MAURO GRASSI
Do you need to test audio equipment, including amplifiers and
speakers, in the field and in the workshop? If so, you could use
this compact and inexpensive digital audio oscillator. It can
produce sine, square, triangle and sawtooth waveforms in the
frequency range from 10Hz-30kHz and features three output
ranges: 20mV, 200mV & 1V.
T
HIS COMPACT HAND-HELD digital audio oscillator will allow you
to quickly test wiring and to diagnose
faults in audio systems. It is ideal for
testing amplifier and speaker set-ups
and is portable and easy to use.
To use it, you simply select one
of four waveforms – sine, square,
triangle or sawtooth – and set it to a
frequency between 10Hz and 30kHz.
The digitally synthesised waveform
is then available at the two RCA outputs. These two outputs are in parallel
and are doubled-up simply for your
convenience. It means you can test
a stereo amplifier and speaker set
simultaneously.
Turning to the front panel, there is a
4-position slide switch that selects one
of three levels for the output signal:
68 Silicon Chip
20mV, 200mV and 1V. Each selected
level can be continuously varied down
to zero with the “Level” control.
There are also three pushbuttons on
the front panel. The two on the right
increase or decrease the frequency
of the output waveform. The output
frequency and the waveform type are
shown on a blue backlit LCD screen.
Pressing the “Wave” button on the
left while at the same time pressing
the “Down” button on the right lets
you scroll through the four different
waveform types: sine, square, triangle
and sawtooth. It’s that easy!
Circuit details
Fig.1 shows the circuit details. It
uses an Atmel microcontroller (IC1) to
implement most of the features.
The unit is powered from a single
9V battery. As shown, the +9V rail
is fed via reverse polarity protection
diode D1 to one pole of a 2P4T (2-pole
4-throw) switch, S4a. In three of the
four positions, the switch feeds the
resulting +8.4V rail on D1’s cathode
to voltage regulator REG1.
REG1, in turn, outputs a +5V rail
which is used to power the microcontroller, while the +8.4V rail from
diode D1 is used to power op amps
IC2a & IC2b.
In operation, IC1 monitors pushbuttons switches S1-S3. These switches
are respectively connected to digital
inputs PD2-PD4 which have weak
internal pull-ups. When a switch is
pressed, the relevant input is pulled
low and this is detected by IC1 and
siliconchip.com.au
siliconchip.com.au
June 2009 69
PD0
PD1
PD5
PD6
PD7
PD4
PD3
PD2
GND
22
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
PC5
PC4
PC3
PC2
PC1
PC0
14
15
16
17
18
19
9
10
28
27
26
25
24
23
30k
30k
30k
30k
30k
30k
30k
30k
DIGITAL AUDIO OSCILLATOR
GND
8
IC1
ATmega8-16PI
PC6/RST
21 Aref
2
3
11
12
13
6
5
4
1
20
AVcc
7
Vcc
100nF
30k
15k
15k
15k
15k
15k
15k
15k
6
4
100k
1 F
NP
2
3
100k
11 12 13 14 10
3
CONTRAST
8
120k
IC2a
2.2k
1
5
1
180
20mV
200mV
1V
10 F
RANGE
S4b
10k
IC2: TL072
R/W
GND
(Z 7006)
16x2 LCD MODULE
D4 D5 D6 D7 D3 D2 D1 D0
9 8 7
EN
RS
2
Vdd
VR1
10k
LCD
CONTRAST
100k
4.7 F
100k
KBL
ABL
100nF
16
15
GND
OUT
6
5
IN
REG1 78L05
4
IC2b
1k
A
K
1N4002
7
+8.4V
100 F
220 F
OUTPUT
LEVEL
VR2
1k
100
POWER
S4a
IN
OUT
CON2
CON1
9V
BATTERY
A
78L05
GND
K
D1 1N4004
Fig.1: the circuit diagram of the Digital Audio Oscillator. The design is based around a microcontroller (IC1), which drives an LCD module and a DAC
made up of a R-2R ladder network and an op amp buffer stage. The blue backlit LCD screen shows the waveform shape and the frequency.
SC
2009
WAVE
S3
DOWN
S2
UP
S1
10nF
47k
+5V
100nF
1 F NP
9V
100 F -–
REG1
78L05
CON1
+
+D1
CON2
4004
10k
10 F
120k
2.2k
S4 (SX2040)
4.7 F
180
15k
15k
15k
30k
15k
30k
30k
30k
IC2
TL072
Z 7006
100k
100k
100k
100k
(LCD MODULE)
30k
100
15k
IC1 ATmega8-16PI
220 F
30k
30k
30k
S1
10k
16
1
WAVE
VR2
2a3452.K
1k
UP
1k
LEVEL
OUTPUT
10nF
15k
S3
VR1
CON3 (TO LCD)
15k
30k
100nF
47k
S2
processed by the internal software.
This sets the waveshape ( sine, square,
triangle or sawtooth) and the frequency and displays the result on a 16x2
LCD module.
As shown, the microcontroller
drives the 16x2 LCD module using its
PC0-PC5 digital output lines. Trimpot
VR1 sets the display contrast, while
power for the LCD is derived directly
from the +5V rail. The 47kΩ resistor
and 10nF capacitor on pin 1 of IC1
reset the microcontroller at switch on.
D-to-A converter
As well as the LCD module, the
microcontroller also drives a digitalto-analog (D/A) converter via its PB0PB7 digital output lines. This D/A
converter is made up of a R-2R ladder
network and has 8-bit resolution. In
DOWN
Fig.2: follow this parts layout to build the digital audio oscillator. Be
sure to install the electrolytic capacitors and semiconductors with the
correct polarity and note the orientation of switches S1-S3.
this case, R = 15kΩ and there are seven
15kΩ resistors and nine 30kΩ resistors
in the ladder network.
The output of any N-stage R-2R
network is given by:
VOUT = DN x V/2N
where VOUT is the output voltage, DN
is the digital value as an N-bit number
and V is the supply rail.
In our case, N = 8 (so 2N = 256), V
= 5 and DN is given by bits PB7 (MSb)
to PB0 (LSb) which are digital outputs
of IC1. The accuracy of such a DAC
is constrained by the accuracy of the
resistors. Note that, in this case, 1%
resistors are used throughout.
The output of the DAC is AC-coupled
to op amp stage IC2a (TL072) via a 1µF
non-polarised (NP) capacitor. This op
amp stage has its non-inverting input
biased to half-supply by two 100kΩ
resistors and is wired as a unity-gain
buffer stage.
Attenuator
IC2a’s output appears at pin 1 and
is AC-coupled to an attenuator stage
(switch S4b and associated parts) via
a 10µF capacitor and 10kΩ resistor. As
shown, the signal is fed to the wiper of
switch S4b which selects the output
level range.
In operation, S4b selects a divider
consisting of the 10kΩ resistor and
either a 120kΩ, 2.2kΩ or 180Ω resistor
to GND, in parallel with the two 100kΩ
bias resistors for IC2b. These selections
correspond to the 1V, 200mV and
20mV amplitude ranges, respectively.
Selecting the 120kΩ resistor provides the 1V range, while selecting
the 2.2kΩ resistor provides the 200mV
range. The 180Ω resistor gives the
20mV range.
Output buffer
This side-on view shows how the LCD module is secured to the PC board
using Nylon spacers and screws.
70 Silicon Chip
The output of the divider is ACcoupled to op amp output stage IC2b,
this time via a 4.7µF capacitor. This
op amp is also biased to half-supply
using two 100kΩ resistors and also
operates as a unity-gain buffer stage.
Its output signal at pin 7 is fed via a
220µF capacitor and series 100Ω resistor to potentiometer VR2 which sets
the output level.
The resulting signal at VR2’s wiper
is then fed to RCA output sockets
siliconchip.com.au
CON1 & CON2 which are connected
in parallel.
Construction
The Digital Audio Oscillator is built
on a double-sided PC board measuring 76 x 62mm. Fig.2 shows the parts
layout.
Begin by carefully inspecting the PC
board for hairline cracks and for shorts
between adjacent tracks. It will be rare
to find any problems but such checks
are easier done at this stage than later
on, when all the parts are in place.
Once you have inspected the board,
start the assembly by installing the
resistors. Table 1 shows the resistor
colour codes but it’s also a good idea
to check them using a DMM as some
colours can be difficult to distinguish.
The diode can then be installed, taking
care to orientate it exactly as shown on
the parts layout diagram.
Voltage regulator REG1 in the TO-92
package can be soldered in next. It can
only go in one way! Don’t force the
body down too close to the PC board
or you may damage its connecting
leads. It should ideally sit about 7mm
off the board.
The non-polarised MKT capacitors
are installed next, followed by the
polarised electrolytic capacitors. Make
sure the latter are orientated correctly.
Note also that the electrolytic capacitors must all be installed so that they
sit flush with the PC board, to ensure
they don’t later foul the lid of the case.
A 28-pin IC socket is used for the microcontroller and this can be installed
now. Be sure to orientate it with its
notched end to the right, as indicated
on Fig.2. Leave IC1 out for the time
being – its plugged in later on, after
some basic checks of the supply rail
have been performed.
IC2 (TL072) is next on the list. It’s
The PC board is secured inside the case using metal screws that go into
integral mounting posts. Note that the battery leads are run under the PC
board and into the battery compartment via a slot in the back wall.
directly soldered to the PC board and
goes in with its notched end towards
switch S4. Be sure not to apply too
much heat at any one time to its pins,
as this could damage it.
The LCD connector (CON3) can
now be soldered in, followed by potentiometer VR1, the two RCA sockets
(CON1 & CON2), the 2P4T switch (S4)
and trimpot VR1. Follow these with
the three pushbutton switches (S1-S3)
making sure that they are orientated
correctly. Note that each has a straight
edge and this must go to the right as
shown on the component overlay.
The last thing to do is to solder in
the battery clip lead. The red lead goes
to the +9V PC pad, while the black
lead goes to the negative (-) pad. These
pads are located at the top of the PC
board, immediately to the left of the
two RCA sockets.
That completes the PC board assembly, apart from plugging in IC1.
As mentioned earlier, that’s done
only after making a few basic checks.
Table 1: Resistor Colour Codes
o
No.
o 1
o 4
o 1
o 9
o 7
o 1
o 1
o 1
o 1
o 1
siliconchip.com.au
Value
120kΩ
100kΩ
47kΩ
30kΩ
15kΩ
10kΩ
2.2kΩ
1kΩ
180Ω
100Ω
4-Band Code (1%)
brown red yellow brown
brown black yellow brown
yellow violet orange brown
orange black orange brown
brown green orange brown
brown black orange brown
red red red brown
brown black red brown
brown grey brown brown
brown black brown brown
5-Band Code (1%)
brown red black orange brown
brown black black orange brown
yellow violet black red brown
orange black black red brown
brown green black red brown
brown black black red brown
red red black brown brown
brown black black brown brown
brown grey black black brown
brown black black black brown
June 2009 71
Fig.3: this oscilloscope screen grab shows a 1kHz sinewave
(yellow trace), as captured at the output. The distortion
waveform for THD+N (blue trace) can also be seen, as well
as the FFT (Fast Fourier Transform) of the distortion. Note
that the highest distortion peak is at the lower harmonics.
Fig.4: an oscilloscope screen grab of a triangular wave at
around 1kHz. This shows that the waveform is very close
to linear on the rising and falling slopes although there
is some very slight drooping discernible at the waveform
troughs.
Fig.5: this shot shows the square wave output from the
unit at around 1kHz. There is a 2% overshoot on the rising
edge of the waveform but little droop. Droop will only be
apparent at low frequencies in the tens of Hertz.
Fig.6: a sawtooth waveform at a nominal 10kHz. As
shown, the actual frequency is 10.4kHz and the RMS
value is also indicated. Note: this screen grab was
obtained with the unit at full level on the 1V range.
Specifications
Note also that the LCD module is not
attached at this stage.
Frequency Range: 10-200Hz in 10Hz steps, 200Hz-1kHz in 100Hz steps
& 1-30kHz in 500Hz steps
Initial tests
Amplitude Ranges: 0-20mV, 0-200mV & 0-1V RMS (output amplitude
adjustable within the selected range)
Waveforms: sine, square, triangle & sawtooth
Frequency Accuracy: ±4%
Total Harmonic Distortion + Noise: approximately 3%
Output connectors: 2 x RCA parallel mono outputs
Power supply: 9V alkaline battery
Current drain: 25mA
72 Silicon Chip
To test the assembly, first connect
a 9V alkaline battery to the battery
clip, then switch on and use a DMM
to check the voltage between the OUT
terminal of REG1 and the body of either RCA socket. You should measure
close to 5V and this voltage should also
be present on pin 7 of IC1’s socket.
If this voltage is correct, you can
jump to the final installation section. If
not, you should disconnect power immediately and perform a few checks:
(1) Are you using a fresh 9V battery?
siliconchip.com.au
Parts List
Performance
W
E CHECKED the Digital Audio Oscillator on our Audio Precision Test
set and the results are shown in Fig.7. Keep in mind, though, that it is
not intended as a high-precision instrument.
For the sinewave output, we measured the THD+N (Total Harmonic Distortion + Noise) over the frequency range with four different bandpass filters
– see Fig.7. The typical THD+N figure was around 3% which is higher than
most amplifier and speaker sets.
While this is not enough to worry about, it means you cannot use this oscillator in precision applications, where low distortion is paramount. It’s quite
good enough, however, for most troubleshooting tasks.
Figs.3-6 on the facing page show screen grabs of the four different waveforms that can be selected. The frequency accuracy is within ±4% across the
whole range from 10Hz to 30kHz.
1 plastic case, 79 x 117 x 24mm,
Altronics H-8971 (supplied
drilled & screen-printed)
1 16x2 LCD with blue backlight,
Altronics Z-7006
2 PC-mount RCA sockets
1 28-pin 0.3-inch machined IC
socket
1 16-way PC-mount FFC/FPC
connector, Altronics P-4516
1 10kΩ horizontal 5mm trimpot
(VR1)
1 1kΩ log pot (9mm PC-mount),
Altronics R-2480B
3 PC-mount pushbutton
switches, Altronics S-1094
1 2-pole 4-position PC-mount
slide switch, Altronics SX-2040
4 M3 x 9mm Nylon spacers
8 M3 x 6mm Nylon screws
1 9V battery snap connector
Semiconductors
1 programmed Atmel ATmega816PI microcontroller (IC1)
1 TL072 dual op amp (IC2)
1 78L05 regulator (REG1)
1 1N4004 silicon diode (D1)
Capacitors
1 220µF 16V
1 100µF 16V
1 10µF 16V
1 4.7µF 16V
1 1µF 16V NP
2 100nF MKT polyester
1 10nF MKT polyester
Fig.7: the sinewave THD+N vs Frequency for four different filter combinations.
The filters range from <10Hz – >500kHz), <10Hz – 22kHz , <10Hz – 30kHz and
<10Hz – 80kHz. The distortion is less with a more restrictive filter.
(2) Is there between 7-8.4V at the cathode of diode D1? If there isn’t, then you
may have D1 in the wrong way around.
(3) If the voltage is still incorrect,
double-check the PC board assembly.
In particular, check for incorrect component orientation and for incorrectly
placed parts. Check also for dry solder
joints on the underside of the board.
Assuming that REG1’s output is
correct, switch off and plug IC1 into
its socket (notched end to the right).
The LCD module can then be installed.
To do this, mount the LCD module
in position on the PC board using four
M3 x 9mm Nylon spacers and eight M3
siliconchip.com.au
x 6mm Nylon screws. The module’s
flexi connector is then plugged into
CON3 on the PC board.
The PC board can now be mounted
inside the case and secured using the
four Phillips-head 10mm screws supplied with the kit. When doing this,
make sure that the two battery-clip
wires pass underneath the PC board
and into the battery compartment – see
photo. The top of the case can then be
fitted into position and secured using
the two Phillips-head 18mm screws.
Your Digital Audio Oscillator is now
complete and ready for use. You can
check that it is working properly by
Resistors (1%, 0.25W)
1 120kΩ
1 10kΩ
4 100kΩ
1 2.2kΩ
1 47kΩ
1 1kΩ
9 30kΩ
1 180Ω
7 15kΩ
1 100Ω
Where To Buy a Kit
This Digital Audio Oscillator was
designed by Altronics who own the
design copyright. A complete kit of
parts is available from Altronics for
$89.00 (Cat. K-2543).
The kit includes the PC board, the
machined case and all specified
components (including a preprogrammed microcontroller) but
does not include a battery.
monitoring its output with a scope or
failing that, feeding its output into an
SC
audio amplifier system.
June 2009 73
|