programmed I/O. The pulse generation code is only two
statements. The period of the square wave is six
instruction cycles which — for the 32 MHz clock — will be
Keep in mind that one instruction cycle is four clock
cycles. This can be trimmed down to four instruction
cycles ( 2 MHz) if a 25% (or 75%) duty cycle is
Program 2 (ASMV- 2) uses delay functions to create
the high and low times. There are both millisecond and
microsecond functions which can be called from the main
loop to generate whatever duty cycle you need — within
the resolution of the clock.
Program 3 (ASMV- 3) is quite a bit more complex than
the previous two. It uses the A/D to read a voltage which
controls the period of a square wave by setting the
timeout value of Timer 1.
There is no capability to have separate control over
the on time and off time. The program uses an interrupt
based on Timer 1 to change the state of the pulse. There
are definitions in the program which allow the Timer 1
clock to be changed.
Program 4 (ASMV- 4) uses the PWM module and A/D
inputs to develop a variable period and duty cycle square
The program was developed starting with the PIC 555
equivalent program and then modified to use the PWM
module. It is well-documented, so it should be fairly simple
There are eight overlapping period ranges from about
62. 4 ns ( 16 MHz) to 67 s (.0148 Hz). The range selection
method is identical to that of the PIC 555 replacement
from the first part of this series.
Schematic 3A shows the debugging connections for
all my PIC programs (I’m currently using a PICkit 3), while
3B shows the application connections for ASMV- 4. Due to
the methods used in ASMV- 3 and ASMV- 4, the processor
doesn’t need to be dedicated to executing the code.
Mims’ Circuit 11 (Schematic 4) shows the 555
connected as a voltage controlled oscillator (VCO), and is
basically the same circuit as FM- 2. The major differences
are the speaker and the potentiometer on the control
voltage input. Normally, in most 555 applications, this pin
has a bypass capacitor on it. For this application, as a
VCO, it’s used as a means to vary the frequency by
controlling the trip point voltages of the two comparators.
Looking at the schematic, you can see that the control
voltage is one input of a comparator which has the
threshold voltage as its other input. Varying the control
voltage changes the frequency of oscillation because the
difference between the trip voltages of the two
comparators is changing. Note that the trigger voltage
point will always be half of the control voltage.
As shown in the Mims book, as the control voltage
decreases from 4.8V, the output frequency increases.
However, an interesting characteristic of the circuit is that
when the control voltage passes through some low value
(about 1.6V when Vcc = 5V), the frequency decreases
until the voltage gets close to 0V and the unit stops
Take a look at Graph 1 which plots the output
frequency vs. the control voltage. The spreadsheet called
42 December 2017
SCHEMATIC 4. 555 voltage controlled oscillator.