EDN logo


Design Ideas: August 1, 1996

Timers generate variable-sweep frequencies

D Hayden,
Hayden Electronics Design, San Diego, CA

The circuit inFigure 1 generates a 4- to 5-kHz output frequency that precisely sweeps a variable amount of 1 to 100 Hz over a variable time of 0.5 to 5.0 sec (1000-to-1 rate range). The resolution is 1 Hz, and worst-case accuracy during the sweep is 3 Hz (0.06%). This circuit was designed to run from an 8-bit PC ISA bus, but any µC with an 8-bit bus and the appropriate control signals can control the circuit. With a 25-MHz clock source, this circuit can generate a frequency as low as 3.052 kHz, and the theoretical maximum is 12.5 MHz, although frequency sweeping would start after approximately 1.3 msec.

The circuit contains three counters: the DT counter (IC1), the up-down counter (IC4 to IC6), and the fast counter (IC7). Exclusive-OR gates IC2A and IC2B allow you to use two clocking signals for normal operation and for data preloading. IC3A's data latch determines the frequency-sweep direction. IC9 holds the lower byte of data for loading the 16-bit counter, IC1. (You can omit this counter if you use a 16-bit bus.) IC2C works as an inverter to generate the WE signal to IC1 for data loading. The circuit clocks the fast counter at 25 MHz to provide the 1-Hz resolution of the circuit at the 4- to 5-kHz operating frequency.

Figure 2 shows the related timing diagram. A sequence of control signals resets and preloads the timers. You can generate the control signals to generate the desired clock and latch signals for this initialization using a PLD, logic gates, or direct control from a data port of a µC. The sequence is as follows:

After initialization, the up-down counter holds a value of half the starting output frequency, at 40 nsec/bit. The value in the DT counter, which is based on the sweep rate and output frequency, determines the update rate of the up-down counter.

Once started, the fast counter starts counting from zero. (The first output is garbage.) When IC7 overflows (Q-output high), the first real data loads into the fast counter from the output of the up-down counter, through IC8A using the XTR input. That same load signal clocks the DT counter, which increments its value from the preloaded value toward overflow. When the DT counter finally overflows, the circuit issues a clock to the up-down counter, through IC3B (for synchronization with the 25-MHz clock) and IC2B.

The up-down counter then changes its value up or down depending on the initialization of IC3A, causing a fine step change in the next half-period of the output frequency. The actual frequency output comes from the Q/2 output of IC7 because each overflow of the fast counter is half the output period. For no frequency sweep, simply initialize the DT counter with 0, so that it will not overflow for more than 6 sec at a 5-kHz output. The controlling hardware must control the generated pulse width via the START/STOP control.

Because the fast counter operates from a fixed 25-MHz clock, the frequency change forced by a changing up-down counter value is slightly nonlinear. For example, because 1/4900 Hz×1/5000Hz=4081 nsec, changing the counter value 100×40 nsec produces some final error, as well as a slightly nonlinear change from 5000 to 4900 Hz. The best method for calculating the counter value is as follows:


(DI #1897)


| EDN Access | feedback | subscribe to EDN! |
| design features | out in front | design ideas | departments | products | columnist |


Copyright © 1996 EDN Magazine. EDN is a registered trademark of Reed Properties Inc, used under license.