time/bit 1 µs (called TAD in the specs) which makes the
conversion time (plus some processing) about 18 µs. The
delayed one shot and astable multivibrator modes read
the ADC twice: once for the delay/off-time and once for
the pulse width. For the astable multivibrator mode, the
reading for each state is taken immediately preceding that
state so that both states are lengthened by the same
amount of time.
For the one shot modes, the ADC is read before the
program looks for the trigger signal so the reading times
do not affect the trigger-to-pulse delay. However, the
reading time does affect the minimum time between
I considered using interrupts to handle the ADC
readings. However, since the interrupt can occur at almost
any time, it would eventually happen when the timing
loop was to terminate, causing the pulse to be delayed
longer or the pulse width to be a little longer. The effect
would be that some pulses would be longer than others. I
felt that having the timing be more consistent was the
Something I noticed on the several PIC12F1572s I
was using is that the ADC seldom returns a value of 0;
even with the input grounded, it almost always reads a
value of 1. This causes the pulse width and delay/off-time
values to be one count larger than you would expect with
a grounded ADC input. I thought about decrementing the
values just prior to entering the timing loops, but decided
against it since this would affect all settings.
All of the processor’s “math” instructions operate on
eight-bit values. However, it has auto-increment and auto-decrement instructions that use 16-bit pointers to access
I decided to use one of these two registers as a 16-bit
counter to contain the ADC value for the pulse width and
delay. Even though this register accesses a memory
location and copies it to the W register, I ignore it.
I use the auto-decrement mode each time through a
loop and test the most significant bit. If it is on, the
register has decremented to a negative value and the loop
is terminated. Using this method saves three instructions
which — in the case of 1 µs resolution — is significant. I did
not need to use this method for the other ranges, but I
chose to use it in order to be consistent.
The gated astable mode operates such that when the
gate is enabled (high), the output pulse will be
immediately generated. This will be followed by the off-time. The program will complete the entire cycle of pulse
followed by off-time before it again looks for the gate.
The re-trigger pulse for the re-triggerable modes can
happen any time during the cycle. The triggering edge of
the re-trigger signal is captured by the processor and can
be a very short pulse (> 25 ns). If a re-trigger is detected,
the current output cycle will be restarted. If the delayed
one shot mode is selected, this means that both the delay
time as well as the pulse width are re-triggerable. This is
the mode I used in my application — as long as audio is
present, it will re-trigger the delay time.
When audio stops for delay time seconds, the delay
time will time out and a pulse will be generated. The pulse
turns on a relay which removes power from the device for
about 20 seconds and then re-applies power. The delay
time must be long enough to allow the device to reacquire the audio signal or the power-off cycle will repeat.
Some measurements for each of the ranges in mode 0
Range 0. Trigger delay: 870 ns–1.25 µs (three period
window); PW for values 0-3 = 3. 3 µs ( 26 periods).
All other pulse widths are about 160 ns wider than
Ranges 1-4. Trigger delay: 880 ns–1.24 µs (three
period window); PW 0V = 3 µs ( 24 periods).
All pulse widths are 3 µs ( 24 periods) wider than
Range 5. Trigger delay: 3. 4 µs– 4. 9 µs (three period
window); PW 0V = 12.0 µs ( 24 periods).
For a non-0V PW value, there may be an additional
12 µs (calculated) for the pulse width.
Ranges 6 and 7. Trigger delay: 14. 2 µs– 19. 6 µs (three
period window); PW 0V = 48 µs ( 24 periods).
For a non-0V PW value, there may be an additional
48 µs (calculated) for the pulse width.
Some measurements for some of the ranges in mode
4 (multivibrator) are with the pulse width and delay/off-time inputs tied together. Ideally, this should yield a 50%
duty cycle square wave:
Range 0. The shortest period with FAST = 0 is 42 µs.
With FAST = 1, it is 8 µs. The narrowest pulse in either
case is about 3. 6 µs. The slight imbalance is due to
Range 1. The shortest period with FAST = 1 is about
27 µs. The narrowest pulse is 13. 2 µs.
If anyone reading this article would like to experiment
but does not have the capability to program PIC
processors, I will be happy to program either a DIP or an
SOIC. Just send me the IC and a SASE.
The source code for this project can be found at the
article link as well as at my website ( www.qsl.net/k3pto).
The source code is well documented and should be easy
to follow. Porting this code to another PIC processor
should also be relatively easy to accomplish for those PICs
that have at least 49 instructions. Some may need minor
adjustments such as changing the RLF to RLCF. NV
December 2016 37
Engineers Mini-Notebook 555 Circuits by Forrest M. Mims,
III ©1984; also see www.forrestmims.org.