EDN

EDN, May 26, 2011

Issue link: http://dc.ee.ubm-us.com/i/43174

Contents of this Issue

Navigation

Page 55 of 63

designideas The circuit in Figure 1 modifies the circuit in a previous Design Idea (Reference 6). It adds the 21st LED, but it modifies the assembler code to use just 98 words without the main rou- tine. Listing 1, the assembler code, is available with the online version of this Design Idea at www.edn.com/110526dia. It can also suit any of a Microchip (www. microchip.com) baseline or midrange PIC microcontroller's eight pins. THE CIRCUIT ADDS THE 21st LED, BUT IT MODIFIES THE ASSEMBLER CODE TO USE JUST 98 WORDS WITHOUT THE MAIN ROUTINE. You can adapt this code for anoth- er type of microcontroller, such as those from Atmel (www.atmel.com) or STMicroelectronics (www.st.com), using the following steps: 1. Build a look-up table of 10 values for seven-segment coding (see table "Code7Segment" in Listing 1). 2. Build a look-up table of 3×7 5V 2 R1 1k VDD 100 nF C1 7 VSS PIC10F2XX 8 10k R2 GP3 GP0 GP1 GP2 5 4 3 5 4 3 Figure 2 The PIC10F2xx series microcontrollers can drive a seven-segment display with three pins. 56 EDN | MAY 26, 2011 EDN 110512DI5135 FIGURE 2 DIANE 100 R5 R4 100 R6 100 1N4148 1N4148 1N4148 G LED7 470 R3 5V NOTES: R1 IS OPTIONAL BECAUSE GP3 IS AN INPUT-ONLY PIN. OTHERWISE, IT IS SAFER TO PUT R1 WHEN USING A TRUE I/O LINE AS INPUT. USE SEVEN SUPERBRIGHT FLAT LEDs, ARRANGED AS A PSEUDO-SEVEN- SEGMENT LED DISPLAY. EF 5 6 AC D 12 34 B A E F G B C D values to store the successive configu- rations for I/O lines, each configura- tion containing only one high output and one low output to drive one LED at a time, for each digit (see table "Cfg2LinesOut" in Listing 1). 3. Build a look-up table of 3×7 val- ues to store the successive high and low state for the I/O lines that are acting as outputs to light only one LED at a time for each digit (see table "Light1LED" in Listing 1). 4. The subroutine DispDigit rotates to the right seven times, through Carry flag, and the seven-segment code of a digit. It then calls the subroutine LEDon each time you set Carry. 5. The subroutine LEDon activates the LED related to the I/O configu- ration code, which you can extract from table "Cfg2LinesOut," and lights it according to the high or low state code, which you extract from table "Light1LED." The subroutine ends by a jump to a critical 1- to 3-msec delay subroutine. Increasing this delay increases the flicker effect, and decreas- ing this delay dims the LED. 6. Cycle digits of units, tens, and hundreds through steps 4 and 5. For the PIC10F2xx series, which contains only three I/O lines, Figure 2 shows an example of driv- ing one digit, and Listing 2 shows the corresponding assembler code. You can access Listing 2 from the Web version of this Design Idea at www.edn.com/110526dia.EDN REFERENCES 1 Anonymous, "Microcontroller pro- vides low-cost analog-to-digital con- version, drives seven-segment dis- plays," EDN, May 10, 2007, pg 80, http://bit.ly/hrcp8g. 2 Raynus, Abel, "Squeeze extra outputs from a pin-limited microcon- troller," EDN, Aug 4, 2005, pg 96, http://bit.ly/gX723N. 3 Jayapal, R, PhD, "Microcontroller's single I/O-port line drives a bar-graph display," EDN, July 6, 2006, pg 90, http://bit.ly/fjb0MU. 4 Lekic, Nedjeljko, and Zoran Mijan- ovic, "Three microcontroller ports drive 12 LEDs," EDN, Dec 15, 2006, pg 67, http://bit.ly/dRlIBN. 5 Gadre, Dhananjay V, and Anurag Chugh, "Microcontroller drives loga- rithmic/linear dot/bar 20-LED display," EDN, Jan 18, 2007, pg 83, http://bit.ly/ hJCs3j. 6 Benabadji, Noureddine, "PIC micro- processor drives 20-LED dot- or bar- graph display," EDN, Sept 1, 2006, pg 71, http://bit.ly/g7ZIQY.

Articles in this issue

Links on this page

Archives of this issue

view archives of EDN - EDN, May 26, 2011