Информация

Активация не завершена. Завершить

Дата регистрации: 2017-02-07 16:02:59

Комментариев: 1

Сайт: http://www.prom-electric.ru

Его последние комментарии:
  • and the microcontroller is operated from a 4MHz resonator. The program displays numbers 0 to 9 on the display with a one second delay between each output. Author: Dogan Ibrahim Date: July 2007 File: SEVEN1.C void main() unsigned char Pattern, Cnt = 0; unsigned char SEGMENTI = 0x3F,0x06,0x5B,0x4F,0x66,0x6D, TRISC = 0; for(;;) Pattern = SEGMENT Cnt ; Pattern = -Pattern; PORTC = Pattern; Cnt++; if(Cnt == 10) Cnt = 0; Delay_ms(1000); 0x7D,0x07,0x7F,0x6F ; PORTC are outputs Endless loop Number to send to PORTC Invert bit pattern Send to PORTC Cnt is between 0 and 9 1 second delay Figure 6.27: Program listing www.newnespress.com Simple PIC18 Projects 319 found and stored in variable Pattern. Because we are using a common anode display, a segment is turned ON when it is at logic 0 and thus the bit pattern is inverted before it is sent to PORTC. The value of Cnt is then incremented between 0 and 9, after which the program waits for a second before repeating the above sequence. Modified Program Note that the program can be made more readable if we create a function to display the required number and then call this function from the main program. Figure 6.28 shows the modified program (called SEVEN2.C). A function called Display is created with an argument called no. The function gets the bit pattern from local array SEGMENT indexed by no, inverts it, and then returns the resulting bit pattern to the calling program. PROJECT 6.6Two-Digit Multiplexed 7-Segment LED Project Description This project is similar to Project 6.5, but here multiplexed two digits are used instead of just one digit and a fixed number. In this project the number 25 is displayed. In multiplexed LED applications (see Figure 6.29) the LED segments of all the digits are tied together and the common pins of each digit are turned ON separately by the microcontroller. When each digit is displayed only for several milliseconds, the eye cannot tell that the digits are not ON all the time. This way we can multiplex any number of 7-segment displays together. For example, to display the number 53, we have to send 5 to the first digit and enable its common pin. After a few milliseconds, number 3 is sent to the second digit and the common point of the second digit is enabled. When this process is repeated continuously, it appears to the user that both displays are ON continuously. Some manufacturers provide multiplexed multidigit displays, such as 2-, 4-, or 8-digit multiplexed displays, in single packages. The display used in this project is the DC56-11EWA, which is a red 0.56-inch common-cathode two-digit display having 18 pins and the pin configuration as shown in Table 6.9. This display can be controlled from the microcontroller as follows: Send the segment bit pattern for digit 1 to segments a to g Enable digit 1 www.newnespress.com 320 Chapter 6 * 7-SEGMENT DISPLAY In this project a common anode 7-segment LED display is connected to PORTC of a PIC18F452 microcontroller and the microcontroller is operated from a 4MHz resonator. The program displays numbers 0 to 9 on the display with a one second delay between each output. In this version of the program a function called "Display" is used to display the number. Author: Dogan Ibrahim Date: July 2007 File: SEVEN2.C This function displays a number on the 7-segment LED. The number is passed in the argument list of the function. unsigned char Display(unsigned char no) unsigned char Pattern; unsigned char SEGMENT = 0x3F,0x06,0x5B,0x4F,0x66,0x6D, 0x7D,0x07,0x7F,0x6F ; Pattern = SEGMENT no ; Pattern = Pattern; Pattern to return return (Pattern); Start of MAIN Program void main() unsigned char Cnt = 0; TRISC = 0; for(;;) PORTC = Display(Cnt); Cnt++; if(Cnt == 10) Cnt = 0; Delay_ms(1000); PORTC are outputs Endless loop Send to PORTC Cnt is between 0 and 9 1 second delay Figure 6.28: Modified program listing www.newnespress.com Simple PIC18 Projects 321 Figure 6.29: Two multiplexed 7-segment displays Table 6.9: Pin configuration of DC56-11EWA dual display Pin no. Segment 1,5 E 2,6 D 3,8 C 14 Digit 1 enable 17,7 G 15,10 B 16,11 A 18,12 F 13 Digit 2 enable 4 Decimal point 1 9 Decimal point 2 www.newnespress.com 322 Chapter 6 Wait for a few milliseconds Disable digit 1 Send the segment bit pattern for digit 2 to segments a to g Enable digit 2 Wait for a few milliseconds Disable digit 2 Repeat these steps continuously The segment configuration of the DC56-11EWA display is shown in Figure 6.30. In a multiplexed display application the segment pins of corresponding segments are connected together. For example, pins 11 and 16 are connected as the common a segment, pins 15 and 10 are connected as the common b segment, and so on. Figure 6.30: DC56-11EWA display segment configuration Project Hardware The block diagram of this project is shown in Figure 6.31. The circuit diagram is given in Figure 6.32. The segments of the display are . For more information visit site www.prom-electric.ru