changes — will only do up to 500 kHz.
If you want to use the PIC and need a higher
frequency, the program can be modified, or you can
start with program ASMV- 4. However, you may
need to program it specifically for your application
since programming a more general-purpose device
(such as the 555 replacement) will usually cause
lower output frequency capability.
The 555 has a fairly linear frequency vs. control
voltage characteristic as shown in Graph 1. In
contrast, the PIC replacement has a very linear
period vs. control voltage response. This will not
work well for those applications which may want to
use an analog signal to modulate the PIC for use in
an FM application.
However, it’s possible to implement a
numerically controlled oscillator (such as is used
in DDS systems) using software in the PIC.
Programs NCO-1 and NCO- 2 use software timing
loops to create an NCO with a 50% duty cycle.
NCO-1 develops a programmable frequency of
up to 400 kHz with about 6 Hz resolution. NCO-
2 allows the frequency to be modified via an
external potentiometer. Its range is adjustable via
definitions in the program.
One feature of the PIC’s A/D that I used in
one of the timing loops is that the A/D result
registers are both loaded simultaneously at the
end of the conversion cycle. This means they can
be accessed during a conversion for any
calculations that may be desired.
The output will have some amount of jitter in
it due to the resolution of the timing loop. There
is a timing value in one of the loops that
determines the full-scale frequency. The
calculations are described fully in the program
Program NCO- 3 uses the NCO
peripheral of the PIC16F18313 to develop
a square wave. Graph 2 plots the output
frequency vs. control voltage of NCO- 3 for
Range = 0. Like the 555 replacement, it
also uses a potentiometer for frequency
control and a voltage divider to select from
among six ranges.
Range 0 is probably best for audio
applications since its range is from 7. 6 Hz
to about 7. 7 kHz in 7. 6 Hz steps. RA4, pin
3, is used to enable the output when it’s
low. There’s only one statement in the
program which needs to be changed if
high-enable is wanted.
Schematic 6 shows the connections for
the NCO- 3 application. Schematic 3A
shows the connections for programming
44 December 2017
SCHEMATIC 6. PIC numerically controlled oscillator.
GRAPH 2. PIC NCO frequency vs. control voltage.