PHOTO 5. THE SPECTRUM OF THE SIGNAL IN PHOTO 4
SHOWS THAT THE THIRD HARMONIC IS ABOUT 32 DB
DOWN. AGAIN, CONSIDERING THE INITIAL WAVE SHAPE,
IT’S NOT TOO BAD. NO HIGHER FREQUENCY HARMONICS
WERE SEEN BEYOND THE FIFTH (JUST VISIBLE AT - 60 DB).
PHOTO 6. USING A 10K RESISTOR FOR R1 INSTEAD OF
1K RESULTS IN SMALL STEPS. BY CHOOSING LARGE
OR SMALL STEPS, THE PROBLEM OF INCONSISTENT
STEP SIZE CAN BE ADDRESSED.
on the same page, but the ones I saw had clock speeds
in the single digits, so they will be slower.
You will note that I used a large resistor and small
capacitor in the filter circuit (R2 and C2). I did this to
reduce the load on the circuit as much as possible.
Smaller resistors and larger capacitors can have the same
frequency response, but the loading effect will be greater.
This circuit also has a high-impedance output and is sensitive to loading.
The differing step sizes do have a convenient property. An equal number of up-steps and down-steps will
always result in a wave that is centered at 1/2 VCC. That
is, it has a DC level of 1/2 VCC. This is because the steps
always get smaller as you move away from that point on
any generated waveform (in sequence). If this was not the
case, the DC level could shift and the wave could bump
into the high or low voltage limit. This would result in a flat
spot, or clipping of the signal.
Making it Better
You can change the step sizes by changing R1,
because R1 controls the amount of current into C1. If you
make R1 larger, the steps are smaller, and vice-versa.
Photo 6 shows that the steps get much smaller and more
consistent when R1 is increased to 10K. However, the
wave is smaller in amplitude. This means more steps for
a larger amplitude, which results in a lower maximum frequency. What we really need is some way of changing the
current steps at will. In this way, we can use low current
steps when there is a large voltage difference and large
current steps when there is a small voltage difference.
Figure 5 shows how this can be done. As before, only
one pin is on at a time. The other one is set to a high-impedance state. By selecting which pin is driving the
circuit, you can choose the size of the step. Of course,
you can use as many different step sizes as you like. This
means that the waveform can be defined as precisely
as you like. The better defined the waveform, the less
distortion there is.
With low frequency signals, C1 may start to discharge
or droop due to internal leakage. This can be reduced
with a good quality capacitor. Alternatively, you could
switch a larger-value capacitor into the circuit.
Conclusion
FIGURE 5. HIGH-FREQUENCY CIRCUIT WITH BIG AND SMALL
STEPS. THIS HELPS COMPENSATE FOR THE INCONSISTENT
STEP-SIZE OF THE BASIC CIRCUIT.
F
o
r
E
l
e
c
t
r
o
n
i
c
s
NUTS & VOLTS
E
v
e
r
y
t
h
i
n
g
Getting good analog signals out of digital ones
can be done fairly easily with a minimum of parts. It
does take some programming effort, and high-frequency audio signals require most of the uC clock
cycles. However, the two general approaches
described have a number of very useful characteristics. Additionally, the procedure that allows components to be switched in and out of your circuit
permits you to dynamically change your circuit as
required. If you experiment with these methods, you
will probably find more interesting applications for
your projects and products. NV
66