MCU offers inexpensive analogue-to-digital conversion

Article By : Charles Small

This versatile conversion circuit detects and displays signal's peak value. It offers a low-cost analogue-to-digital conversion and a three-digit, seven-segment display.

A previous article showed how to utilise shift registers to increase a microcontroller's output capabilities (Reference 1). This expanded design idea provides low-cost analogue-to-digital conversion and a three-digit, seven-segment display. Although applicable to other microcontrollers, the circuit in the figure uses a Microchip PIC12F675 controller and three multiply sourced 74AC164 serial-input/parallel-output shift registers.

[EDNAOL 2016JUN06 AN 02Fig]*Figure: A low-cost microcontroller captures an analogue voltage, converts it to a peak reading, and displays the results in decimal format on LED displays.

The circuit accepts incoming signals of 0 to 5V. The microcontroller, IC1, performs the analogue-to-digital conversion and subsequently converts the binary-voltage value to BCD (binary-coded-decimal) format. Next, the microcontroller converts the BCD values to hardware-specific seven-segment-display masks and shifts the masks to the 74AC164 registers, IC2 through IC4, which in turn drive the seven-segment displays.
Listing 1 implements an additional function. Instead of displaying each input value as it's converted, the microcontroller operates as a peak detector. When the maximum value changes, the microcontroller updates the three-digit display. A pushbutton switch, S1, resets the maximum value. You can modify the code to apply other functions to the input data and calculate and display the data in other formats. In addition, you can modify the interrupt-driven conversion process to accommodate different sampling rates. When you modify the sampling rate or the ISR (interrupt-service routine), ensure that the ISR completes execution within a single sample period.

Raynus, Abel, "Squeeze extra outputs from a pin-limited micro-controller,"EDN, Aug 4, 2005, pg 96.

This article is a Design Idea selected for re-publication by the editors. It was first published on May 10, 2007 in

Subscribe to Newsletter

Leave a comment