Zibb

Design Idea

Use printer port as programmable frequency generator

Edited by Bill Travis and Anne Watson Swager

K Kanniappan, IGCAR, Tamil Nadu, India -- EDN, 10/11/2001

A simple and inexpensive circuit (Figure 1) and a simple C program (Listing 1) are all you need to turn your PC's printer port into a programmable frequency generator. Using a few low-cost and readily available components, the circuit occupies little space and is easily attachable to the printer port. The circuit has advantages over a 555-based astable multivibrator in that it eliminates the tedious task of adjusting a potentiometer while you watch a frequency counter or oscilloscope. With the circuit in Figure 1, you need only enter the desired frequency, and the PC does the rest. The circuit uses a MAX5130 low-power, programmable, 13-bit DAC, IC1; an OP07 buffer; and an AD537 VFC (voltage-to-frequency converter). The PC controls the DAC using a three-wire serial interface. It also uses the data lines D0 to D2 of the data port (0×378h) of the printer interface to send the  (chip-select), data, and CLK (clock) signals to the DAC. Depending on the data it receives from the PC, the DAC produces a voltage output of 0 to 4.0955V in 8192 steps with a step resolution of 0.5 mV. Thus, a data word of 0×000h produces a DAC output of 0V, and a data word of 0×1fffh produces a DAC output of 4.0955V. Using the 2.5V internal reference, the DAC output and the data input follow the equation VOUT=2.5(DATA/8192)×GAIN.

After IC2 buffers it, the DAC output drives the VFC and sets its frequency output according to the following equation: fOUT=VOUT/(10(R1+R2)C1) Hz. For the values of R1, R2, and C in Figure 1 and the cited DAC-output range, the output of the VFC and hence the frequency of the programmable-frequency generator varies from 0 to 10 kHz in 8192 steps with a frequency resolution of 1.22 Hz. You choose and trim the values of R1 and R2 to produce a current range of 0 to 1 mA for a DAC output of 0 to 4.0955V. These values ensure good linearity (typically 0.01%) between VOUT and fOUT. Potentiometers P1 and P2 adjust fOUT at the lower and higher ends of the frequency range, respectively. The C program in Listing 1 obtains the desired frequency from the user and calculates the required output from the DAC to apply to the VFC. It then works out the ACTUALDATA to send to the DAC for mode control. The d2b routine converts the ACTUALDATA into 16-bit binary data. The program enables the DAC ( ) low and then serially clocks the binary equivalent of ACTUALDATA, starting one bit at a time from the MSB to the LSB, to the data pin of the DAC. With the LSB set at the data pin, the low-to-high transition of the clock latches the ACTUALDATA completely into the DAC and sets fOUT to the desired value. You can easily change the frequency range by changing the value of C. For example, with R1 and R2 unchanged, you can extend the frequency to 100 kHz by changing C to 0.001 µF instead of 0.01 µF. You can also increase the frequency range by using a VFC with a higher frequency capability.

Is this the best Design Idea in this issue? Vote at www.ednmag.com.



Reed Business Information Resource Center

Featured Company


Related Resources

ADVERTISEMENT

ADVERTISEMENT

Related Content

 

By This Author

There are no additional articles written by this author.


ADVERTISEMENT

Knowledge Center



Technology Quick Links

EDN Marketplace


©1997-2009 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other Reed Business sites