For an application requiring the display of readings of 0.01 to 0.99V, you can use a 4MHz crystal and Microchip’s PI16F84A microprocessor for I1. To display the rightmost three digits of readings in the 0.001 to 0.999V range, use a 20MHz crystal and a PI16F84A-20 microprocessor.
Choose 15- to 33-pF values for capacitors C1 and C2, which the PIC’s data sheet describes. Listing 1, which is available online at www.edn.com/060622dil, includes the full assembler source code for the PI16F84A. The most critical portion of the firmware comprises a subroutine that provides a precision time delay according to the following steps:
1. Configure RA4 as an input to sense the voltage across C3 during the charging interval. When you configure RA4 as an input, it serves as a Schmitt trigger with 1.6V low-threshold and 3.2V high-threshold voltages when drain-to-drain voltage is 5V.
2. Configure RB7 as an output and set it high to begin charging C3. Initialize a counter (register 0CH) to its maximum value of FFH.
3. Decrement the counter in a loop until RA4 senses a low state. At that time, C3 charges to nearly 66% of the power-supply voltage.
4. Use the time it takes to produce a low on the RA4 input as a jump value in the linearity correction look-up table to extract a value for the two-digit LED readout.
5. Configure RB7 as an input and set it low to discharge capacitor C3.
6. After a time delay, repeat Step 2.
To round out the design, another software subroutine solves the problem of driving a two-digit LED display at adequate visibility with a minimum amount of current. Although an LCD would use less current, LCDs aren’t visible in darkness. The display subroutine examines the eight bits of the units and tens—registers 11H and 12H—and tests each one in sequence; if the subroutine sets a bit, then the subroutine puts a short-duration high state on its corresponding segment-driver line, RB. Doing so lights only one LED segment at a time, and, consequently, the maximum current consumption of the circuit remains relatively constant even if you add a third LED display to build a 999-count millivoltmeter.