This is only a preview of the May 2003 issue of Silicon Chip. You can view 28 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 "WidgyBox - A Guitar Distortion Effects Unit":
Items relevant to "A 10MHz Direct Digital Synthesis Generator":
Items relevant to "Printer Port Hardware Simulator":
Articles in this series:
Purchase a printed copy of this issue for $10.00. |
Direct Digital Synthesis (DDS) makes it very easy to design a low-cost,
high-performance function generator – one of the handiest pieces of
test gear you can have. This one can be set to any specific frequency
between 1Hz and 10MHz and offers both sine and square wave output.
T
he 20MHz Low Cost Function
Generator I described in the
August 96 issue of “Electronics
Australia” has proven very popular,
with thousands having been built.
The low cost, simple construction
and wide bandwidth made it a very
attractive project.
However, there were two problems with that design – the lack of
a frequency display and being able
to set the frequency to exactly what
you wanted. To overcome these, one
kit supplier bundled the function
generator with another frequency
counter kit.
So it is not surprising that many
people have asked for an updated design with a built-in frequency display.
While a frequency display would be
relatively easy to add, it would add significantly to the cost and complexity
of the project. In addition, the analog
32 Silicon Chip
nature of the original design meant
that temperature drift would also be
an issue.
This new design overcomes these
problems by adding a frequency display and digital frequency selection,
while still maintaining the low-cost
approach.
The design
The design is based on an Analog
Devices AD9835, a complete 50MHz
by David L Jones*
(clock) Direct Digital Synthesis (DDS)
sinewave generator on a single chip.
The MAX038 used in the previous
design is analog in nature and setting
the exact output frequency is difficult
unless you have many ranges with fine
adjustment.
Going digital with the DDS chip is
the obvious way to go: it allows you to
set the output frequency exactly from
1Hz to 10MHz in 1Hz steps and there
is effectively no drift with temperature
or time as the output frequency is
crystal-locked.
As the AD9835 is clocked at 50MHz,
in theory it is capable of generating a
sinewave up to 25MHz. At this frequency, the output waveform quality
is more difficult to control and amplify,
so 10MHz was taken as the arbitrary
upper limit.
This results in a good quality, low
distortion, large output signal level
over a 0-10MHz range.
While 10MHz is not as high as the
20MHz+ in the original design, it is
still sufficient for most applications
and is way beyond the 2MHz or so
of most commercial analog bench
generators.
www.siliconchip.com.au
Low Cost
1HZ –10MHz
DDS Function
Generator
It’s a tiny, tiny chip!
It’s nice – but by no means essential.
Our frequency display is now oneTo set and display the frequency tenth the cost of an LCD and is easier
Unfortunately, the AD9835 DDS
to assemble.
chip is only available in a 16-pin you really only need to display one
To also help reduce the cost, the PC
TSSOP (Thin Shrink Small Outline digit at any one time, in which case
a single 7-segment LED display can board has been designed to fit into a
Package) surface-mount package,
be used.
standard UB3 Jiffy box, with no wirwhich makes it challenging(!) to solder
ing required – everything mounts on
You do need some other indication to
by hand.
A TSSOP package has half the pin tell you what digit you are setting – but the PC board.
RCA output connectors were chopitch of your typical SOIC surface a simple LED can do that.
sen in preference to BNC connectors,
mount IC package, a mere 25-thou
as the PC board mounting
(0.635mm). Compare it with
Specifications:
RCA connectors are about
the 74HC14 SO14 package
one-tenth the cost of the
also used in this design.
BNC type.
Waveform Generation: 32-bit DDS, 10-bit DAC
More will be mentioned
In fact, you can buy a
Distortion:
<1% at 1kHz
about how to solder this
PC board mounting RCA
Frequency Range:
1Hz to 10MHz in 1Hz steps
device later.
connector plus an RCA-toFrequency Display:
“Sliding Window” 7 digit
There are other DDS chips in
BNC convertor for less than
(EEPROM frequency retention)
the Analog Devices DDS prodthe cost of a BNC PC board
User Input:
Three push buttons
uct range with easier-to-handle
mount connector.
Sinewave Output:
0-5Vp-p adjustable, 50Ω
packages but they are much
Squarewave Output:
CMOS/TTL compatible, 50% duty cycle
bigger, more expensive and
Main controller
Output Connections:
RCA
don’t have a nice serial interPower:
9VAC
100mA
plugpack
A PIC16F628 8-bit miface like the AD9835.
cro- controller was chosen
My first prototype for this
as the main controller. It
design used an LCD panel for
has 2KB of internal FLASH
The end result is a single 7-segment
the frequency readout but this would
have significantly increased the cost LED display with a row of 3mm LEDs program memory, 224 bytes of RAM
of the project. So I thought about it to indicate which digit of the output and 128 bytes of EEPROM. This is
for a while and came to the realisation frequency is being displayed and set. adequate for our control program and
So the row of LEDs correspond to data storage.
that you don’t really need to display
This chip serves three purposes.
the entire frequency at any one time. X,XXX,XXX Hz.
www.siliconchip.com.au
May 2003 33
Fig.1: inside the AD9835 DDS IC. Its operation is explained in the text. On the facing page is Fig.2, the circuit diagram.
One is to control the display and
switches, the second is to send the
necessary control commands to the
AD9835 DDS chip and the third is
to store the output frequency in the
internal EEPROM.
The frequency set by the user is
stored in the internal EEPROM and
this same frequency is automatically
set when the project is next powered
up.
The 4MHz internal RC oscillator
is used to lower system cost and to
free the extra pins for I/O functions.
There are no critical absolute timing
requirements in the project, so a crystal
oscillator is not required.
How DDS frequency
generation works
The internal block diagram of the
AD9835 (Fig.1) shows its operation
as well as that of a basic Direct Digital Synthesis (DDS) generator. A DDS
generator consists of three major
components – a phase accumulator, a
sine-wave lookup table (usually con34 Silicon Chip
tained in ROM) and a digital-to-analog
convertor (DAC). The phase accumulator is also commonly referred to as
a Numerical Control Oscillator (NCO),
although no part of a DDS actually
“oscillates”.
As sinewaves are non-linear in
nature, they are not that easy to generate accurately, even using standard
sampling techniques. On the other
hand, the “phase” of a sinewave is
completely linear in nature, from
0-360°, and thus lends itself to be more
easily generated.
Using a reference clock and the linear aspect of the phase, a DDS generator
can generate very accurate sine- waves
of almost any frequency, completely in
the digital domain.
The phase accumulator basically
performs an integration function and
generates a linear phase “ramp” in
proportion to the desired frequency,
which is contained in the 32-bit register
FREQ0. The sine (or cosine in the case
of the AD9835) lookup table converts
the linear phase ramp into a sinewave.
As sinewaves are completely symmetrical every 90°, the lookup table
only needs to store one quarter of the
waveform, with some appropriate
control logic to map this over the full
cycle. (Different DDS devices have
differing ways to do this).
Even though the AD9835 contains
a 32-bit frequency control register, a
32-bit (232 memory bits) lookup table
is not required, as the AD9835 only
has a 10-bit DAC.
So the (co)sine lookup table does
not need to be much more accurate
than this; in this case it is only 12 bits.
This ensures that the accuracy of the
signal is determined entirely by the
DAC resolution and linearity.
How it works:
As you can see from the schematic
(Fig.2) there isn’t much to the design.
IC3 does all the frequency generation,
IC2 handles the control and display,
while IC1 and IC4 provide output
drive.
IC3 is programmed by a custom
www.siliconchip.com.au
www.siliconchip.com.au
May 2003 35
All components mount on the one single-sided PC board, although some are on
the back (track side). Note how the LEDs stand up to poke through the case
lid. The PIC chip should be socketed to allow for any future firmware
upgrades. This pic is of an early protoype – the one presented is V2.0.
3-wire serial control bus from the
micro- controller (IC2). Data and commands are transferred in 16-bit words.
The serial interface is run asynchronously to the main clock and can be
run at any speed determined by the
host micro.
IC3 has various modes and internal
registers that must be defined before it
will output a frequency, and these are
explained in the data sheet for those
who are curious. IC3 is also capable
of frequency and phase modulation
of the output signal, both of which
can be controlled by either the serial
bus or an external pin. For the sake of
simplicity and cost reduction, these
features have not been implemented
into this design.
The actual output frequency is
determined by the value in the 32-bit
FREQ0 register. The value in FREQ0
will be equal to F/(50MHz/232), where
F is the desired output frequency.
From this equation you will see that
with our 50MHz oscillator we can get
approximately 12mHz resolution and
this value will also equal our output
frequency uncertainty (ignoring crystal accuracy). In the case of a 1Hz
output frequency, the FREQ0 register will contain the value 86 which
equates to 1.001Hz, not quite 1Hz but
close enough!
At the low end of the frequency range
the frequency accuracy will be 0.1%
worst case, while at the high end the
frequency accuracy can be controlled
to a staggering one part in four billion.
Low distortion was not a major de36 Silicon Chip
sign requirement, so for simplicity no
measures were taken to improve this.
The total harmonic distortion (THD)
is around the 1% mark, which is adequate for most general applications.
External output filtering can be added
to improve this if desired.
IC3 is clocked by XTAL OSC1, an
industry standard 50MHz TTL/CMOS
8-pin DIP crystal oscillator. The stability of the generated output signal will
be dependant upon this clock but for
this low-cost application any grade
oscillator will suffice.
There are many brands of oscillator
that match this standard footprint –
some come in plastic DIP, while others
come in a metal can package.
IC3 requires digital and analog
power and ground pins. These are
individually decoupled at the power
pins and run as separate lines from
the regulators.
IC3 provides a current output on pin
14, which is converted into a voltage
by R4. C11 is an optional filter capacitor and is not fitted in the standard
design. R2 sets the full scale DAC
output signal current level, which in
this case is approximately 3.9mA. This
is already at a maximum value that
will not compromise the performance
of the chip.
Thus the output voltage across R4
will be approximately 1V p-p referenced above ground, as IC3 is powered
from a single power rail. This signal
is AC-coupled by C12 and referenced
to ground and user adjusted by VR1.
The signal is then amplified by IC1
which operates with a gain of 4.9,
as set by R5 and R6. This gives an
The early prototype board has a capacitor and two resistors strapped on to the
back. In the final version these are “on top”. The main purpose of this photograph
is to show the components which are soldered to the back of the board, especially
the tiny AD9835 TSSOP IC (top, centre) which requires great care.
www.siliconchip.com.au
Fig.3: front (top) and
back (bottom) sides
of the PC board
showing component
placement. It is a
single-sided board
as far as tracks are
concerned; some
components are on
the track (copper)
side. The majority
of components are
polarised or need
to be mounted a
certain way (for
example, the three
pushbutton switches).
Note carefully the
comments about
soldering IC3 (and
IC4 for that matter).
approximate maximum output signal
level (at all frequencies) of ±2.5V peak.
Thus the final sinewave output level
is adjustable from 0-5V p-p.
IC1 provides a low impedance buffered output and R7 provides a nominal
50Ω output impedance. IC1 can be either a National Semiconductor LM6361
or an Elantec EL2044. The EL2044
is the recommended device as it has
a slightly higher bandwidth, so will
provide a higher signal level output at
the high end of the frequency range.
IC4 is a hex Schmitt inverter, with
C13, R1 and R3 providing a level shift
function to bias the ground-referenced
sinewave input signal to half the supply rail (suitable for a 5V TTL input).
The Schmitt input squares up the sinewave and gives a CMOS/TTL output.
The 7-segment display and digital
LEDs are multiplexed onto the same
output pins on IC2. The common cathode line for both displays goes back to
a separate pin on IC2. IC2 is thus able
to “switch” alternately between displaying the 7-segment display and the
digit LEDs. This is done in firmware
and each display is turned on for a 5ms
burst at a rate determined by the main
loop. As long as it is greater than 50Hz
or so you won’t see any flicker – all the
LEDs appear to be continuously on.
The pushbutton switches are debounced in the firmware by a small
delay of a few hundred milliseconds
after each key press.
The power supply is a typical halfwave rectified AC input with positive
and negative 5V regulators (REG1 &
REG2).
Heat dissipation in the regulators
Parts List – 10MHz DDS Function Generator
1 PC board, 123 x 56mm; coded
04105031
1 UB3 Jiffy box (130 x 67 x
44mm)
1 18-way IC socket (for IC2)
3 momentary action PC-mounting
switches
2 RCA sockets, PC-mounting (with
BNC adaptor if required)
1 knob to suit potentiometer shaft
4 12mm x 3mm tapped spacers
4 20mm x 3mm bolts, nuts and
washers
www.siliconchip.com.au
Semiconductors
1 EL2044 or LM6361 opamp (IC1)
1 16F628 PIC microcontroller, programmed with DDSFRQ20.HEX (IC2)
1 AD9835 DDS generator (IC3)
1 74HC14 hex Schmitt trigger
(IC4)
1 LM7805 +5V regulator (REG1)
1 LM79L05 -5V regulator (REG 2)
1 50MHz TTL oscillator (XTAL OSC1)
1 FND500 7-segment LED display (DISP1)
7 3mm red LEDs (LED1-7)
2 1N4001 silicon diodes (D1, D2)
Capacitors
2 470µF 10V PC electrolytic (C12,13)
1 470µF 25V PC electrolytic (C14)
1 100µF 25V PC electrolytic (C15)
2 10µF 10V PC electrolytic (C1,2)
2 100nF MKT SMD (0.2p) (C6,7)
5 100nF ceramic (C3,9,10,16,17)
2 10nF ceramic SMD (0.2p) (C4,5)
Resistors
(1/4W 1% unless noted)
1 47Ω
1 120Ω
1 270Ω (SMD)
3 470Ω
2 1.5kΩ (SMD)
1 3.9kΩ (SMD)
2 470kΩ
1 1kΩ potentiometer
May 2003 37
The PC board is connected to the case lid via four tapped spacers. Suitable cutouts and holes in the lid allow the switches, LEDs and pot shaft to poke through,
while the 7-segment display can also be seen through a cut-out.
will depend on the input voltage level
from the plugpack. Ensure that this
is not too high – a 9V AC plugpack
is recommended as a maximum. The
plugpack should be rated at 100mA
or greater.
Parts availability
All of the components are available
off-the-shelf for those who wish to con-
struct the project from scratch. Farnell
carry the “hard to get” bits like the
AD9835, AD6361, 50MHz oscillator
and surface mount 74HC14.
As far as the PC board is concerned,
it is not out of reach of home manufacture using good lithography techniques, despite the TSSOP track/pad
pitch being extremely small.
It is however recommended that a
proper solder-masked PC board be obtained as this will make construction
a lot easier.
The HEX file is available for download for non-commercial use from the
SILICON CHIP website (www. siliconchip.com.au) and the author’s website
at www.alternatezone.com
Short form kits and PC boards may
also be available from the author.
Given the popularity of the original
design, it is probable that kits will be
made available by major suppliers in
due course.
Construction
Start construction with the AD9835
TSSOP IC (see separate panel). This
way, there will be no other components to obstruct you and the board
will sit flat and steady on your bench.
This IC is by far the most difficult
component to solder in this kit; indeed, it may be the most difficult com-
Soldering the AD9835 TSSOP IC
Soldering the AD9835 is the most difficult aspect of project construction and unless you have the right tools and
experience it is likely that you will have problems.
Don’t underestimate how hard this will be: the pin pitch
is 1/4 that of a regular IC and half that of a standard SOIC.
If you have a solder-masked PC board then your job will
be a lot easier, as the solder mask will help stop the solder
bridging between pins.
As a minimum you will need a good temperature-controlled soldering iron with a fine tip suitable for surface mount
soldering, 0.45mm solder and tweezers. A chiselled tip is
much better than a conical tip, which will have difficulty
making good thermal contact.
The ideal tip to use is the “wicking” chisel type which
has a small cavity in the middle of the tip to help “wick” the
solder back off the joint, this helps to keep the amount of
solder on the pins to an absolute minimum.
Proper 0.45mm surface-mount solder should be used –
anything bigger will be a nightmare.
Alternatively (if you have them available), proper surface-mount solder paste and a hot-air surface-mount
soldering gun will give you a first class job.
A magnifying lamp will come in very handy for this job –
in fact, it is probably essential as many people will have to
do the soldering under a magnifying lamp. You would need
really good eyesight to solder and inspect the job without
a magnifying lamp.
The best approach is to apply a small amount of solder
to one of the corner pads of the chip. Then use tweezers
to place the chip over the pad (ensure correct orientation!).
You can then reheat this pin and move the chip with the
tweezers to get it properly centred.
Before you solder any more pins, double check the orientation of the chip: desoldering the chip later is an option
you don’t even want to think about.
38 Silicon Chip
Once the chip is aligned on the pads correctly then
solder the pin on the opposite corner so the chip will
hold in place.
A “wicking” motion of the soldering iron away perpendicular from the pin is your best shot at avoiding bridges
between pins.
The regular soldering technique of applying the iron to
the pin and pad and then applying the solder on the other
side of the joint will not work in this situation. Neither the
soldering iron tip nor solder are small enough to allow this.
You will find that excess solder will form around the joint
no matter how hard you try to control how much you use.
So you will have to just try and “wick” it away from the joint.
The biggest killer when hand soldering surface mount
components is too much heat. Not only can excessive heat
lift pads and crack tracks but worse, it can crack or destroy
the component internally. Only solder one joint at a time and
let the device cool before moving on. Do not apply heat to
any joint for more than one or two seconds at most.
Patience here could help prevent a big headache later.
www.siliconchip.com.au
These two ’scope shots show both analog and digital outputs at two different frequencies. The shot on the left is at 1kH
and shows a pretty good result on both sine and square waves. The other shot is at 5.736MHz (no, this frequency is
nothing special!) and shows a still-quite-usable waveform in both cases. The ringing on the square wave, in particular, is
due to the signal being unterminated – it would be significantly better into a load.
ponent you will ever have to solder!
Having successfully soldered and
checked the TSSOP, the other 0805
passive components and the SOIC
package will be much easier to solder
– but similar rules apply. Watch the
orientation of the SOIC.
Finish construction with the usual
through-hole components. The PIC
chip should be socketed to allow for
firmware updates.
The 7-segment display will require
a regular wide IC socket cut to size to
stand it off from the PC board.
The LEDs should be mounted about
10mm proud of the PC board. The
easiest way to do this and to ensure
alignment of all the LEDs is to cut a
10mm strip of cardboard and place this
between the legs of all the LEDs while
soldering. Watch the LED polarity.
The PC board is mounted behind
the front panel on four 12mm spacers
You may notice on the prototype
that R1, R3, and C13 are retrofitted
on the underside of the board. The
published design has these components added to the top of the PC
board, as shown on the overlay.
escaping from any of the components!
Next, measure the outputs of the regulators, they should be plus and minus
5V (respectively).
In use
When first powered up, the project
will most likely be set to 0Hz, so there
will be no output waveform. This
could vary though, depending on the
initial contents of the EEPROM bytes
in the PIC chip.
In either case, press the SFT
(SHIFT) button to select which digit
will be displayed on the 7-segment
display. Use of the SFT button allows
you to quickly determine the output
frequency.
The INC button will increment the
currently displayed digit and will
wrap back to zero. There is no ability
to decrement the number other than
the wrap around.
Using SFT and INC does not update
the frequency at the output. To do this
you must push the SET button. This
sets the output frequency and also
stores the frequency in the internal
EEPROM memory, so this frequency
will be automatically reloaded when
the project is next powered up.
Remember that the output frequency
will only change when you press the
SET button, so the display will only
reflect the actual output frequency
when you have not touched the INC
button since the last time the output
frequency was set.
When using the TTL/CMOS output,
ensure that the output level control
is set to maximum, as this output is
generated directly from the amplified
sine -wave output.
SC
Happy generating.
* david<at>alternatezone.com
Testing
Before you power up the project,
check for any shorts, especially on
the surface-mount devices. Do a
visual inspection and a multi-meter
check. Don’t try to probe the pins
of the TSSOP chip directly; instead
probe the other end of the appropriate track on a larger component.
Apply power to the project and
ensure that the vital smoke is not
www.siliconchip.com.au
Full-size artwork for the Function Generator front panel can also be photocopied
and used as a drilling template for the case lid.
May 2003 39
|