This is only a preview of the February 2000 issue of Silicon Chip. You can view 34 of the 96 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 "A Digital Voltmeter For Your Car":
Items relevant to "Build A Safety Switch Checker":
Items relevant to "A Sine/Square Wave Oscillator For Your Workbench":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
By RICK WALTERS
Build this sine/square
wave oscillator for
your workbench
Do you want a good quality audio oscillator
that does not go “boingg” when you switch
ranges? And has constant output amplitude
as you sweep over each range and from
range to range? If so, this could be the
oscillator for you. It covers the frequency
range from 2Hz to 20kHz and is suitable for
a wide range of audio applications.
58 Silicon Chip
N
ORMALLY, THE FIRST choice
of anyone contemplating
building or buying an audio
oscillator is a Wein bridge type. These
have the advantage of low distortion
(usually) but their output amplitude
often bounces all over the place as
you sweep over each frequency range
and is even worse when you switch
ranges. It is possible to avoid these
problems with careful design but the
circuit will end up being more com-
Fig.1: block diagram of the oscillator.
IC1c is a high frequency oscillator
and its output is divided by 1, 10,
100 or 1000 by IC7b or IC8. It is then
further divided by 2 and 5 before
being applied to a divide-by-10
ring counter (IC2a, IC4 & IC5). This
drives a resistor network which
produces a stepped waveform which
is fed to switched capacitor filter,
IC6.
plicated (see our low distortion design
in the February & March 1999 issues).
The second choice for an audio oscillator is typically a function generator but while these usually have good
amplitude stability, their distortion
content is usually fairly average. But
now you have a third choice with this
design which uses digitally generated
sinewaves and employs a switched
capacitor filter.
While thumbing through the Jaycar Electronics catalog some time
ago, I came across an “IC bargain”,
an MF4CH-50 4th order switched
capacitor Butterworth low-pass filter,
for the trivial sum of $1.50. This set
me thinking (I do that occasionally)
about what level of distortion we
would get if we fed a pseudo sinewave
(digitally generated) into that sort
of filter. Many moons later, this low
cost audio oscillator is the outcome
of those profound thoughts.
The oscillator is housed in a plastic zippy box measuring 157 x 95 x
50mm. It has three knobs on the front
panel and these are the 4-position
range switch, the frequency control
and the sinewave output control. As
well, there is a toggle power switch
and three RCA sockets for the sinewave output and two square wave
outputs. The circuit is battery operated but could be run from a plugpack
if you wish; more on that later.
Theory of operation
Before we go too far, we need
to explain just what is a 4th-order
switched capacitor Butterworth lowpass filter. Let’s do the low-pass filter
first because it’s easy: as its name sug
gests, a low-pass filter is one that lets
low frequencies through (passes) but
progressively blocks (attenuates) the
higher ones. The frequency at which
the response is 3dB down is called
the turnover frequency.
Now what does 4th-order mean?
A 1st order low-pass filter has an
attenuation slope of 6dB per octave
above the turnover frequency and
so a 4th-order has four times this or
Performance
•
•
•
•
•
Sinewave output ...............................................2Hz - 20kHz, 0-2V RMS
Square-wave output ................................2Hz - 20kHz, 5V peak-to-peak
Square-wave x100 output ....................200Hz - 2MHz, 5V peak-to-peak
Sinewave distortion ....................................................... less than 0.85%
Current consumption............................. 15mA from +5V, 6mA from -5V
24dB per octave. This steep rolloff of
high frequencies is used to get rid of
the higher harmonics of our digital
sinewave.
The term Butterworth describes
a filter response which is flat (0dB)
until it begins to roll off. Other types
of filters have a peak or ripples in the
response before the rolloff begins. For
audio work, the Butterworth response
is usually the best and most suitable.
Switched capacitor filters
Any conventional filter circuit
can be designed to roll off at any
given frequency but this frequency
can only be altered by changing the
relevant resistor or capacitor values.
For a 4th-order filter, this would mean
changing the values of four resistors or
four capacitors in precisely the same
ratio. This makes things very complicated because an oscillator based on
a variable 4th-order filter would then
need a five ganged potentiometer, or
a five ganged capacitor (if we include
one for the actual frequency control).
In practice, this approach would be
just too expensive.
This is where the MF4CH-50
switched-capacitor filter comes into
the picture. It has four internal capacitors which are rapidly switched in
and out of circuit to vary their values.
Furthermore, the more rapidly they
are switched, the less the effective
capacitance.
FEBRUARY 2000 59
60 Silicon Chip
More specifically, the turnover
filter frequency of the MF4CH-50 is
1/50th of its clock frequency, so if we
clocked it at 50kHz it would begin to
rolloff at 1kHz.
Fig.1 shows the general concept
of the oscillator and IC6 is the
MF4CH-50 switched capacitor filter.
IC1c is a high frequency oscillator
and its output is divided by 1, 10,
100 or 1000 by IC7b or IC8. It is then
further divided by 2 and 5 before
being applied to a divide-by-10 ring
counter (IC2a, IC4 & IC5). This drives
a resistor network which produces a
stepped waveform which is a very
rough approximation of a sinewave
which is 1/50th of the frequency
output from IC2b.
IC6, the MF4CH-50, is also clocked
by the output of IC2b and so its turnover frequency exactly matches the
output of the ring counter. It effectively removes the switching hash
from the waveform, leaving a clean
sinewave.
Circuit description
The circuit of Fig.2 is a little more
complex but operates as we have just
explained. While it may look to have
a lot of circuit elements, it uses only
nine low-cost ICs.
Let’s start with IC1c, the master
oscillator. It is a 74HC132 quad NAND
gate with Schmitt trigger inputs
configured as an oscillator, with the
maximum and minimum frequencies
adjusted using trimpots VR2 and VR3.
These are set so that the sinewave frequency varies from just under 2kHz to
just over 20kHz on the highest range
and potentiometer VR1 then becomes
the main frequency control.
The frequencies for the other three
ranges are generated by successively
dividing this main frequency by 10
in IC8 and IC7b.
These four frequencies are fed to
range switch S1a which directs the
selected frequency to IC2b (one section of a 4013 dual-D flipflop) and also
Fig.2 (left): the master oscillator is
IC1c and since it is a Schmitt device
it requires trimpots VR2 & VR3 to set
the maximum and minimum
frequencies. Both IC1a & IC1b are
unused but their inputs have been
tied to related parts of the circuit.
The circuit can be powered from a 9V
plugpack, as shown in Fig.12.
to IC1d which inverts and buffers the
signal and feeds it to the front panel
as SQUARE x 100.
This signal is only an exact square
wave on the lower three ranges which
come from IC8 and IC7b. The top
range comes direct from IC1c and its
output is not a true square wave but
has a high time of around 45% (the
low time being 55%) of the oscillator’s
frequency. As the oscillator output is
inverted by gate IC1d, the high and
low periods are also inverted (55:45).
IC2b divides the selected frequency from S1a by two, giving an exact
square wave which is required for
the clock input of IC6, the switched
capacitor filter. IC2b also drives IC3,
a 4017 connected to divide by five.
The output of IC3, pin 10, is fed to
the clock inputs of flipflops IC2a, IC4b
& IC4a and IC5b & IC5a. These five
flipflops are connected as a twisted
ring counter which divides the clock
frequency by 10. The Q outputs of
four of the flipflops are summed by the
10kΩ and 16kΩ resistors to produce a
stepped waveform and this is fed to
the input of the switched capacitor
filter, IC6.
The stepped input waveform and
the filtered output can be seen in the
scope waveforms of Fig.3. Quite a
dramatic improvement, eh?
Twisted ring counter
What’s a twisted ring counter we
hear you asking? In a normal D-type
flipflop (such as IC2b), the Qbar
output (pin 12) is connected back to
the D input (pin 9). This causes the
Q output to change from high to low
and back to high again on sequential
low to high transitions of the clock
signal at pin 11.
In our twisted ring counter the Qbar
output of IC5a is tied back to the D
input of IC2a. Assuming the Qbar
output of IC5a was low, the Q output
of IC2a would be low and this low
would then be propagated through
the chain until the low level was
applied to IC5a. This would cause
the Q output to go low and the Qbar
output to go high. Thus a high would
be presented to pin 5 of IC2a and it
would be propagated through the
chain. It is “twisted” because a low
level on IC5a’s Q output (the main
output) propagates a high through the
chain and vice versa.
While it is hard to visualise, what
happens is that a high is moved
Parts List
1 PC board, code 04102001, 149
x 71mm
1 plastic box, 50mm x 90mm x
150mm with aluminium lid
1 front panel label, 150 x 85mm
1 2-pole 6-position PC mount
rotary switch with two nuts (S1)
1 DPDT miniature toggle switch
(S2)
3 panel-mount RCA sockets
2 25kΩ linear potentiometers
(VR1, VR4)
3 knobs to suit
1 2kΩ horizontal mounting
trimpot (VR2)
1 200kΩ horizontal mounting
trimpot (VR3)
2 9V batteries
2 battery snap connectors
Semiconductors
1 74HC132 quad NAND Schmitt
trigger (IC1)
3 4013 dual D flipflop
(IC2,IC4,IC5)
1 4017 decade divider (IC3)
1 MF4CH-50 switched capacitor
filter (IC6)
2 74HC390 dual decade divider
(IC7,IC8)
1 TL071 op amp (IC9)
1 78L05 5V regulator (REG1)
1 79L05 -5V regulator (REG2)
Capacitors
1 100µF 16VW PC electrolytic
1 10µF 16VW PC electrolytic
4 0.1µF monolithic ceramic
1 .033µF MKT polyester
1 .0033µF MKT polyester
1 820pF 10% ceramic
1 330pF 10% ceramic
1 220pF 10% ceramic
1 33pF 10% ceramic
Resistors (1%, 0.25W)
1 68kΩ
3 10kΩ
1 47kΩ
2 3.3kΩ
1 33kΩ
1 1kΩ
2 16kΩ
For 9V AC plugpack operation
Delete 9V batteries and snap
connectors
1 panel mounting connector to
suit 9V AC plugpack
2 1N4001, 1N4004 power diodes
2 100µF 25VW PC electrolytic
capacitors
1 tag strip
FEBRUARY 2000 61
The PC board is mounted on the back
of rotary switch S1 which in turn is
mounted on the front panel. However,
you may prefer to further secure the
board to the front panel by fitting
a mounting pillar at each corner,
particularly if the unit is going to be
moved about.
through the ring and this is followed
by four more highs. As each Q output
goes high, the stepped waveform of
Fig.3 is produced by summing the Q
outputs. Once the first high reaches
pin 1 of IC5a (pin 2 will be low), a
series of lows is shifted through the
ring, causing the steps to fall towards
0V and this cycle repeats over and
over.
The clock frequency fed to the ring
counter is also divided by 10 in IC7a,
giving a true square wave output at
the same frequency as the sinewave
output.
We found that the output amplitude from IC6 (MF4CH-50) increased
on the highest range, starting from
around 10kHz. The resistor/capacitor
network between the output of IC6
and the sinewave level control VR4
help to flatten the output in this region
although even with these components
the response is still +1dB at 20kHz.
Op amp IC9 is used as a sinewave
output buffer with a gain of 3, to
62 Silicon Chip
make up for the losses in IC6 and the
two 3.3kΩ resistors in series with the
output level control (VR4). It also sets
the maximum output level to 2V RMS.
While the switched capacitor filter
does a good job of producing a clean
sinewave, there is still some switching hash present and we do some
more filtering in IC9. This is done by
using S1b, the second pole of S1, to
switch a capacitor across the feedback
resistor of IC9 on each range. This
helps to attenuate the high frequency
switching spikes. This causes a rather
interesting effect. The measured distortion actually decreases slightly as
the frequency increases on each range,
rather than the normal case where the
distortion increases as the frequency
increases.
Mind you, since the hash is 50 times
the fundamental, it is not the slightest bit audible until the fundamental
frequency drops below about 200Hz.
The sinewave output is symmetrical above and below the 0V line
(ground) and is variable from 0V to
2V RMS which should be sufficient
for any normal audio work.
We fitted two voltage regulators
on the PC board and these are fine
for battery operation. If you plan to
use a plugpack you will need to add
two capacitors and two diodes which
can be wired to a tag strip. This is
explained in more detail later.
Output & distortion waveforms
As noted in the performance panel,
the distortion content of the sinewave output is less than 0.85% but
this depends on the frequency and
the bandwidth of the measurement.
The scope wave
forms of Figs.4, 5,
6 & 7 demonstrate this. Fig.4 shows
a 1.1kHz waveform on the top trace
and the lower trace is the modulated
distortion product which is mainly
the 50kHz switching hash. This is
equivalent to a harmonic distortion
content of 0.83%, taken with a measurement bandwidth of 80kHz (ie, all
Fig.3: these scope diagrams show the operation of the
switched capacitor filter (IC6). The top trace is the
stepped waveform and the lower trace is the sinewave
output.
Fig.4: the sinewave output at 1.1kHz (top) has a very slight
“jagginess” due to 50kHz switching artefacts. The lower
trace is the modulated distortion product – mainly the
50kHz switching hash (0.83% THD <at> 80kHz bandwidth).
Fig.5: a 1kHz waveform is shown on the top trace, while
the lower trace is the distortion waveform, measured with
a bandwidth of 22kHz. (THD 0.26%).
Fig.6: the top trace is a 10kHz sinewave while the lower
trace is the residual harmonic content measured with an
80kHz bandwidth (THD 0.285%).
Fig.7: the top trace is the sinewave output at 19.6kHz
and the lower trace is the distortion which has a level of
0.76%, measured with a bandwidth of 80kHz.
Fig.8: the 20kHz sinewave output (top) and the squarewave output. The lefthand cursor is not set correctly and
so the frequency measurement of 20.7kHz is wrong.
FEBRUARY 2000 63
Fig.9: this is the component layout for the PC board and it also shows the wiring to the front panel.
harmonics and noise up to 80kHz are
included in the measurement).
Fig.5 shows a 1kHz waveform on
the top trace but this time the distortion waveform on the lower trace has
been measured with a bandwidth of
22kHz. This has removed most of the
50kHz hash from the measurement
and results in a THD figure of 0.26%.
The top waveform of Fig.6 is a
10kHz sinewave and the lower trace is
64 Silicon Chip
the residual harmonic content measured with an 80kHz bandwidth. The
result is a distortion measurement of
0.285%. Note that for an output at
10kHz, the switching hash would be
at 500kHz and this would be well and
truly eliminated by an 80kHz filter.
Fig.7 shows the output waveform
at 19.6kHz and its accompa
nying
residual distortion which has a level
of 0.76%, measured with a bandwidth
of 80kHz. In this case the switching
hash would be at 980kHz.
Finally, Fig.8 shows two waveforms
at 20kHz. The top is the sinewave
output and the lower trace is the
accompanying square wave output.
Construction
All the circuit components, with
the exception of the two potentiometers, are mounted on a PC board
We used double-sided tape to secure the batteries but you might prefer to use
battery holders fastened to the bottom of the case.
measuring 149 x 71mm and coded
04102001. The component wiring
diagram and the connections inside
the case are shown in Fig.9.
While we have made provision for
mounting pillars at each corner of
the PC board, our method of mounting is somewhat simpler – we just
supported it on the back of the rotary
switch, S1.
It is a good idea to check the PC
board against the artwork of Fig.11
before beginning the assembly. Check
for any undrilled holes or broken or
open circuit tracks and fix any defects
that you find.
Capacitor Codes
Value
IEC Code EIA Code
0.1µF 100n 104
.033µF 33n 333
.0033µF 3n3 332
820pF 820p 821
330pF 330p 331
220pF 220p 221
33pF 33p 33
Resistor Colour Codes
No.
1
1
1
2
3
2
1
Value
68kΩ
47kΩ
33kΩ
16kΩ
10kΩ
3.3kΩ
1kΩ
4-Band Code (1%)
blue grey orange brown
yellow violet orange brown
orange orange orange brown
brown blue orange brown
brown black orange brown
orange orange red brown
brown black red brown
5-Band Code (1%)
blue grey black red brown
yellow violet black red brown
orange orange black red brown
brown blue black red brown
brown black black red brown
orange orange black brown brown
brown black black brown brown
FEBRUARY 2000 65
The connections between the PC board and the front panel hardware can be
run using light-duty hookup wire. Keep the lead lengths reasonably short to
maintain a neat appearance (you can use cable ties if you wish).
tion correct (not upside down) before
soldering the 12 outer lugs.
The locking tab on the switch can
now be set to position 4 (so that the
switch has only four positions). This
done, solder the battery leads to the
switch and complete the wiring, as
shown in Fig.9. By the way, we used
a zippy box with an aluminium front
panel as the frequency control is sensitive to hand capacitance.
If you wish to use a plugpack instead
of batteries, you will need a 9V AC
plugpack and a rectifier circuit wired
to provide positive and negative supplies, as shown in Fig.12. This circuit
consists of positive and a negative
half-wave rectifiers, each feeding a
100µF electrolytic capacitor. The extra
components can be wired onto a length
of tagstrip.
Testing the oscillator
This view shows how the PC board is
supported on the back of the rotary switch.
Note that this switch mounts on the copper
side of the board.
Begin by installing the PC pins,
wire links and resistors, followed by
the trimpots and IC sockets, which are
optional. This done, insert the smaller capacitors, followed by the two
electrolytic capacitors which must be
installed the right way around.
Next, solder in the CMOS ICs. To do
this, earth the barrel of your soldering
iron to the 0V line on the PC board and
solder the supply pins of each IC first,
followed by the other pins.
You can now install the two regulators. Make sure that you put each one
in the correct position otherwise the
circuit definitely won’t work.
must fit two wire links on the back of
the switch as shown in Fig.10. This
done, insert it in the PC board from
the copper side. The lugs should be
flush with the laminate side.
Check that you have the orienta
Calibrating the oscillator
Rotary switch mounting
The rotary switch is mounted on the
copper side of the PC board (as shown
in the photos) and this means that it
is impossible to solder the two centre
pins of the switch to the PC board.
Therefore, before you mount it, you
66 Silicon Chip
You will need a multimeter and a
frequency counter or an oscilloscope
to calibrate the oscillator.
Turn on the batteries or plugpack.
Check for +5V at pin 7 of IC9 and -5V
at pin 4. These voltages should be
within 0.5V. If the voltages are correct
turn off the power and insert the ICs if
you used sockets. Power up again and
check for +5V on pin 14 of IC1, IC2,
IC4 & IC5, pin 16 of IC3, IC7 & IC8,
and pin 7 of IC6. Also check for -5V
on pin 4 of IC6.
With the sine level control fully
clockwise and the 200Hz - 2kHz range
selected, you should measure about
5.6V peak-to-peak with your oscilloscope. If using your multimeter, you
should be able to measure 2V RMS at
the sinewave output.
Using an oscilloscope or a frequency
counter check that the X1 square wave
frequency is the same as the sinewave
frequency and that the x100 output is
also correct.
Fig.10: the two centre pins of
the rotary switch must be wired
as shown before it is installed
on the copper side of the PC
board.
The last step is to calibrate the
oscillator. Turn VR3 and VR1 fully
clockwise and adjust VR2 until the
sine
wave frequency is 20.5kHz on
the 2-20kHz range. Now turn VR1
fully anticlockwise and adjust VR3
until the frequency is 1.95kHz. There
will be some interaction between the
two presets, so you may have to make
these adjustments a couple of times to
get the frequencies just right. As the
lower ranges are generated by digital
division they will track exactly.
Fig.11: here are the actual size artworks for the PC board and the front panel.
If you cannot get the frequency adjustment right, set VR3 and VR1 fully
clockwise and VR2 to centre. Check
the oscillator frequency then alter the
220pF capacitor on pin 10 of IC1c until
you are close to 20.5kHz. Then follow
the calibration instructions once again.
If the frequency is too high, fit an
extra capacitor in the holes adjacent to
the 220pF capacitor. If the frequency
is 20% high, add a 47pF capacitor.
Conversely, if the frequency is low
you will have to reduce the 220pF to
180pF or less, then perhaps fit a small
SC
value as described above.
Fig.12: use this circuit if you wish to power the
oscillator from a 9V AC plugpack.
FEBRUARY 2000 67
|