This is only a preview of the July 1990 issue of Silicon Chip. You can view 49 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 "Digital Sine/Square Wave Generator; Pt.1":
Articles in this series:
Articles in this series:
Articles in this series:
Articles in this series:
|
Digital waveform generation
using a computer, Pt.4
This month, we have produced a PC board for
an upgraded D-A converter & filter circuit. We
also have a 5-¼in floppy disc full of upgraded
software so that you can use your computer as
a function generator or tone burst generator.
By STEVE PAYOR
This series started out as a simple example of computer interfacing; a practical demonstration of
how a little bit of electronics could
enhance your PC, and vice-versa.
On the way, we created a
log/linear frequency sweep generator, a tone burst generator, and a
sine/triangle/square wave function
generator. That's not bad value,
really, for a handful of resistors, a
64
SILICON CHIP
36-pin socket and some optional
filtering components.
PCB and floppy disc
In this final article, we will put it
all together with the introduction of
a PC board (to make the filter easy
to build) and a floppy disc with fully
executable programs.
But first, let's recap the story so
far :
The February 1990 issue, pages
68-71, described the parallel
printer port and showed how to access the various bits directly. We
also showed how a binary-weighted
resistor network could turn the 8
data bits into an analog voltage.
In the March 1990 issue, pages
80-84, we showed how a low-pass
filter could remove the "steps"
from the digitally generated
waveform. On page 83, we gave a
listing of a log/linear frequency
sweep program, which proved very
useful for adjusting the "flatness"
of the filter passband response. The
frequency sweep program is written in TURBO BASIC and has data
rate of 20k samples/sec. When combined with the simple third-order
LC filter , it can generate high quali-
a
HXACT VALUES
ALL RESISTORS 1%
OUTPUT
S1b--------,
S1a
* 2. 769k
: FIL TEA
.._ LOAD
68[1
2.7k
J. ---,
(9) 07
* 5.583k
5.6k
50pF.
3.3k
(8) 06
-!-
C1
* 11.21k
5.6k
5.6k
(7) 05
22k
OUTPUT
tRIM
VR1
2.2k
<5kf
.,.
470!1
(6) 04
FILTER TYPE
180k
(4) 02
3RD ORDER
CHEBYSHEV
: -0.1d8 AT 4.4kHz
I
5TH ORDER
CHEBYSHEV
-0.1dB AT 36kHz
C1b
L2
C3
.0047
.01
38.3mH
.033
.001
.001326
5.943mH
.006308
7.618mH
.005537
+ 50pF
LOAD
100k SAMPLES/
SECOND
.001
297pF
4.415mH
.005782
8.335mH
.006424
+ 50pF
LOAD
100k SAMPLES/
SECOND
L4
C5
SUITABLE
DATA RATE
C1a
20k SAMPLES/SECOND
180k
180k
(3) 01
(16,19) TO (30,33) GND
5TH ORDER
BUTTERWORTH
-0.1dB AT 22kHz
o---~Mr---
7
(1) - S T R O B E 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 CRO TRIGGER
CENTRONICS
PIN NUMBERS
ty waveforms up to 4.5kHz.
In the May 1990 issue, pages
92-97, we presented two more programming examples. The program
on page 93 is for generating IHF
standard audio tone bursts. It is
also written in TURBO BASIC and has
the same data rate and frequency
limitation as the frequency sweep
program. The program on pages
94-96 is a wide range (20kHz plus)
sine/triangle/square wave function
generator. The program itself is in
GWBASIC but it uses a high speed
subroutine, written in 8088 machine code, to achieve a data rate of
100k samples/sec.
OUTPUT
D-A CONVERTER/FILTER
Fig.1: this D-A converter & filter circuit plugs into the Centronics port of your
computer. Note that you have a choice of filters: 3rd or 5th order Chebyshev,
or 5th order Butterworth (see text). In most cases, the 3rd order Chebyshev
filter will be adequate (see text).
programs which can be run directly
from DOS.
The executable versions of these
programs have been considerably
enlarged, to make them more "user
friendly". For example, they will
automatically locate the 1/0 ad-
dress of your parallel printer port.
The data rate compromise
You may well ask, why not use
the highest possible data rate in all
the software? Well, for short,
repetitive waveforms, like sine,
No compiler needed
All these programs [and more)
are on the floppy disc. The source
listings of these programs are exactly as published. However, the
source listings of the TURBO BASIC
programs are mainly for information only. Since most readers will
not have a copy of the TURBO BASIC
compiler, we are including compiled and executable versions of these
The 5th order Chebyshev filter is suitable for the function generator program
but not for the frequency sweep & tone burst programs. The 36-pin Centronics
socket is soldered directly to the PC board.
]ULY 1990
65
data rate, the filter components can
be calculated to suit.
Filter choices
The 3rd order filter is easier to build than the 5th order types. Note that the
Centronics socket fitted to this board is the "solder bucket" type which has a
pin spacing of .085-inch.
triangle and square waves, the
highest data rate of took samples/
sec is fine. However, for the long
waveforms produced by the frequency sweep and tone burst programs, the number of bytes required becomes excessive.
For example, a 0.5s tone burst
would require 50,000 bytes at a
data rate of 100k bytes/sec. Not only is this getting close to the maximum allowable array size (64k
bytes) but you would also have to
wait an awfully long time for the
program to set up this waveform. A
data rate of 20k samples/sec is
much more realistic for this task.
Execution speed
If you have an 8087 mathematics
co-processor, the compiled programs will use it, resulting in a considerable saving in the time re-
quired to set up the waveform. For
example, setting up a 0.5s tone
burst takes 4 seconds with the coprocessor and 41 seconds without
it. Note: the data rate during
waveform output remains unaffected by the presence of the coprocessor.
What will affect the data rate is
the speed of your CPU and/or 1/0
card. The programs allow you to
enter sample times other than 50µs.
So, for example, if you have a
toMHz Turbo XT, you may find that
a tkHz waveform comes out as
2. tkHz. To correct this, try entering
a sample time of 23.85µs at the
start of the program.
The best way to determine the
actual sample time on your machine
is by experiment, so the first thing
to do is get the D-A converter working. Once you have determined the
Where to buy the PC board & software
An etched PC board plus a 360K 5 ¼-inch floppy disc of the software
are available from M. Radvanyi, PO Box 49, Kingswood, NSW 2750.
The price is $39.95 (includes instructions on running the programs
plus packaging & postage) Note: does not include on-board components. Please make payment by cheque (to M. Radvanyi) or by mail
order.
The floppy disc includes three separate executable programs which
can be run from DOS: frequency sweep, tone burst generator and
function generator (sine, triangle & square waves). Also included are
some GWBASIC programs for those who wish to create their own
waveforms. The software is easy to use and all frequencies and functions for each program are simply entered into the opening menu.
Note: copyright of the PC pattern and the software is retained by the
author.
66
SILICON CHIP
The low-pass filter is only required if you wish to remove any
visible traces of the D-A steps from
the waveforms. With the machine
code software, you certainly won't
hear any difference because the
lowest alias frequency will be
50kHz. So, if you don't have a CRO,
you can leave the filter section of
the PCB empty, and replace the
switch with a wire link. Capacitor
CtA can still be fitted, if you wish,
to absorb the D-A glitches.
You have a choice of filters from 1st order to 5th order in fact.
We have listed the component
values for suitable 3rd and 5th
order filters on the circuit diagram.
In most cases, the 3rd order
Chebyshev filter will be adequate.
This only requires one inductor and
is easy to align (see the CRO photo
on page 81, March 1990}.
Unless you are an experienced
constructor, we suggest you stick to
the 3rd order filter, even for the
higher data rate. (In this case, simply get out your calculator and divide
the values for Cl, 12 and C3 by 5).
Don't forget to fit a link in place of
14.
The main advantage of the 5th
order filters is that their steeper
cutoff allows a passband which extends closer to the theoretical limit
of half the sampling frequency. For
example, with a took samples/sec
data rate, the 5th order Chebyshev
filter allows a frequency response
up to 36kHz ( - 0.tdB). However,
the very steep cutoff results in some
ringing on square and sawtooth
waveforms.
The 5th order Butterworth (maximally flat) filter will give slightly
cleaner waveforms. However, the
- 0.tdB bandwidth is reduced to
only 22kHz. Its principal advantage
is that it can be adjusted to be dead
flat up to 20kHz. In practice
however, such precise alignment is
rather difficult.
Changing the parameters
You can scale the 1 & C values, to
take into account different source
impedances or to move the cutoff
frequency.
PARTS LIST
36 .
WAVEFORM
OUTPUT
GNO
GND
19
CRO TRIGGER
OUTPUT
36-PIN
CENTRONICS
SOCKET
Fig.2: parts layout for the 3rd order filter. C3 consists of three capacitors
connected in parallel to give the required value. The circuit values shown are
for a data rate of 20k samples/sec but the filter can also be built for the
higher data rate by dividing the L & C values by 5.
1 PC board, code PC-Driven
Waveform Gen.
1 5.25-inch 360K floppy disc,
"Silicon Chip Digital
Waveform Generation
Software"
1 36-way IEEE-488 type
Centronics socket
1 2k0 or 1 OkO miniature
horizontal trimpot (see text)
4 PC stakes
Resistors (0.25W, 1 %)
5
1
1
1
3
1
1
1
1
180k0
27k0
22k0
18k0
5.6k0 (one selected for
55830 ± 1 00, two selected
for 11,2100 ±500)
3.3k0
2.7k0 (selected for 2,7010
±50)
4700
680
Optional .components
for low-pass filter
CRO TRIGGER
OUTPUT
PINS 1 TO 18 SOLDERED
TO COPPER SIDE OF PCB
36 PIN
CENTRONICS
SOCKET
Fig.3: parts layout for the 5th order filters. The winding details for the
inductors are given in an accompanying panel. You wHI need a CRO to
accurately align the filters (by adjusting the inductors) to give a flat response
across the passband.
For example, to change the 3rd
order filter to accommodate a
1.200k0 source impedance, multiply all the L values by 1.200/1.083
and divide all the C values by this
same amount. This gives ClA +
ClB = 13.lnF, 12 = 42.44mH and
C3 = 29.8nF.
Now let's say you have a compiled "C" program which has a data
rate of 60k samples/sec. Dividing
the above L & C values by 3 will
make the filter suitable for this data
rate.
Assembling the PCB
The PCB is designed to be
soldered directly to a 36-pin "Centronics'' socket. There are two
types of socket available. The
"solder bucket" type has a pin-topin spacing of .085-inch, while the
JDC type has a 0.1-inch pin spacing.
If you have the latter type of socket,
cut the finer connector pattern off
the end of the PCB.
Solder pins 1-18 directly to the
PCB pads and connect the signal
ground pins (19-30 & 33) using three
tinned wire links on the component
side of the board, as shown in the
wiring diagram (and photograph).
Sorting the resistors
Before fitting the resistors, it is
desirable to check them with a
digital multimeter. The most important ones are those at the top of the
ladder - in particular, the resistor
for the MSB should be within 0.2%
for an accuracy of 1/2 LSB.
Therefore, try to get the resistors
for bit D7 to add up to 2.769k0. Of
the three 5.6k0 resistors, put the
one closest to 5.583k0 in the D6
position and try to get a pair which
add up to 11.2 lkO in the D5 position. Normal 1 % accuracy will do
for all the lower bit positions.
By the way, the resistor values
1 DPDT slide switch
1 or 2 RM 1 0 ferrite core
assemblies (each consisting
of two matched core halves,
inductance adjuster, two
mounting clips and coil
former.) AL values to suit
required inductance (see
text)
length of 0.25mm, 0.315mm
or 0.4mm grade 2 enamelled
copper wire (see text)
Miscellaneous
Assorted polystyrene, silver
mica, or high-stability foil/film
capacitors for C1 a, C1 b, C3 &
CS (see Fig.1 ).
have been optimised for standard
TTL output source and sink impedances. If your printer port is
driven directly from a custom LSI
chip, some modification of the
resistor network may be necessary.
The most likely scenario is insufficient drive to the high-order bits.
If you have access to a CRO, run
the 0-255 test ramp program and
you will probably see small
"backward" steps 1/4 and 3/4 of
the way up the ramp and a larger
backward step at the half-way
JULY 1990
67
Pins 19-30 of the Centronics socket
are all joined together using a tinned
wire link. These pins, along with pin
33, are then connected to earth on
the PC board.
This is the opening menu for the tone burst generator program. The default
parameters give the IHF standard but you can change any parameter simply
by typing in a new value and hitting RETURN.
point. Take a large value resistor
(eg. 330kn) and temporarily shunt
the resistor for the second-mostsignificant bit (D6). Note the effect
and keep trying different shunt
resistors until the waveform is
perfectly straight at the 1/4 and 3/4
points.
Below: the 5th order filter also uses
parallel connected capacitors to give
the required values. Note how the pot
cores are mounted.
68
SILICON CHIP
Now trim the MSB (D7) until the
gap at the half-way point disappears, and that's it. The secret is to
start trimming from the lower bits
up.
Output level trimming
The D-A output can be trimmed
to lOmV per step with the 3.3kQ
resistor and the Zkn trimpot. This
gives an output voltage range of
0.1 V to 2.65V for a digital input of 0
to 255. For audio applications. you
may wish to fit a lOkQ trimpot.
which will allow you to trim the output to 2.828V peak to-peak (ie. exactly 1V RMS for sine waves).
The output trimming circuit may
seem a little unusual but it performs a vital role in maintaining the
linearity of the D-A converter. The
heavy DC load to ground helps to
stabilise the TTL "high'· level output voltages.
The output impedance is approximately l.083kQ when trimmed for
2.55V p-p and l.200kQ when trimmed for 2.8V p-p. (You will need this
information later when calculating
the filter components).
At this stage. the D-A converter
is complete and you can test it using
a digital voltmeter and the DC
How To Wind The Inductors
The inductors are wound on
PCB-mounting RM 1 0 ferrite core
assemblies. Use AL 400 cores for
inductors greater than 1 0mH and
AL 250 cores for inductors less
than 10mH.
If you are using a different core
type, you will need to know its AL
value in order to calculate the
number of turns required . The
calculation is quite l:limple:
(1 ) . Express the desired inductance in nH; eg, 38.3mH =
38,300,000nH
(2). Divide this by the AL value of
the core; eg, 38 ,300,000 -+- 400
= 95,750 .
(3) . Take the square root; eg,
(93,250)½ = 309.4 = the required number of turns (309 and a
half will be near enough) .
If the core has an adjuster, find
out how much it can increase the
inductance and subtract half this
amount before doing the above
calculation. For example, the AL
400 core has an adjustment range
of 0 to +20% while the AL 250
voltage software, or a pair of headphones and the signal generation
software.
Note that the D-A network will
produce a current output (eg. 0 to
2.55mA) when used with a short
circuit load, such as a pair of headphones. However, with the filter in
circuit, the load should be higher
than 2k0 to maintain a flat frequency response.
Winding the inductors
Full instructions for calculating
the number of turns are given in the
accompanying panel. Note that
RM10 cores are recommended. For
preference, use A1 400 cores for inductors greater than 10mH, and A1
250 .:ores for inductors less than
10mH. The coil formers for both
cores will accommodate up to 400
turns of 0.25mm grade 2 enamelled
copper wire, 250 turns of 0.315mm
wire, or 180 turns of 0.4mm wire.
The A1 400 core has an adjustment range of Oto + 20%, while the
A1 250 core has an adjustment
core has an adjustment range of 0
to + 1 7 % . Thus, when calculating
the number of turns, reduce the
desired inductance by 10% and
8.5% respectively. This will put
you in the middle of the adjustment
range .
Thus, to obtain 38.3mH on an
AL 400 core, we have to calculate
the number of turns for an inductance of 38.3mH less 10% =
34.47mH. This gives 293.5 turns.
We used 0.25mm enamelled copper wire, for which there is ample
room within the core window.
Alternatively, if you don't want to
bother with aligning the filter, leave
out the adjusters and the inductance will be accurate to within
±2% as is, provided you count the
turns correctly.
Suitable cores, formers, mounting clips and adjusters are
available in boxed sets from
Radiospares Components for
$6 .83 each, plus sales tax. The AL
400 set is stock number 228-258
and the AL 2 50 set is stock
number 228-242.
range of O to + 17%. So, when
calculating the number of turns,
reduce the desired inductance by
10% and 8.5% respectively. This
will put you in the middle of the adjustment range. Alternatively, if
you don't want to bother with aligning the filter , leave out the adjusters and the inductance will be
accurate to within ± 2% as is, provided you count the turns correctly.
On the subject of accuracy, it is
well worth selecting the exact
capacitor values with the aid of a
digital capacitance meter, especially if you intend to use fixed inductors. With adjustable inductors, the
filter "flatness" can easily be
restored, even if the capacitors are
5% off.
Note that the PCB will accommodate up to three capacitors in
each location, so that standard
values can be combined to give the
exact value required. For best
results use polystyrene, silver mica
or similar low temperature coefficient capacitors.
~
Problems?
... and you
don't have our
NEW
1990/91
148 page
electronic parts
and accessories
catalogue ...
Its our latest
TRADE
catalogue for
the consumer
ARISTA ... Your one-stop
problem solver.
... Stylus ...
... Plugs, Jacks and Sockets...
.. .Batteries .. .
...Cable .. .
...Tools and Technical Aids .. .
...Plug and Power Packs .. .
...Car/Auto Accessories .. .
... Boxed Hi Fi Speakers .. .
... Raw Replacement Speakers ...
...Speaker Accessories ...
... Telephones and Intercom ...
...Public Address Accesso ries .. .
... Security and Alarm Accessories .. .
... TV/Video/ Antenna Accesories .. .
... Videocam Accessories .. .
...Audio Accessories ...
... Headphones...
... Computer Accessories .. .
...Microphone Accessories .. .
...Mixers, Amplifiers, Equalizers ...
Just about anything
you want ...
Get your catalogue
complete with
"Recommended Retail Prices"
free from your local ARISTA
dealer or send $2.50 P & H
and your return address to:
ARIST~
ELECTRONICS PTY LTD
PO BOX 191,
LIDCOMBE, NSW, 2141
JULY 1990
69
|