Welcome to www.agpgames.com ---- HANGZHOU KinCony ELECTRONICS CO.,LTD.
About Us Contact Us          Our Patents Our Articles        Forum      SiteMap    Chinese Version

Chapter 1. Overview Chapter 2. Emulation Guide Chapter 3. Build Your First Project Chapter 4. In System Programming
Chapter 5. USB Interface Installation Chapter 6. LED Display Application Chapter 9. FAQ Chapter 10. System Configuration and Service
 
Chapter 7. Basic Experiments
7.1. Experiment with LED 7.2. Experiment with Flowing LEDs 7.3. Experiment with Keys 7.4. Experiment with Beeper
7.5. Experiment with Relay 7.6. Experiment with LED Display 7.7. Experiment with Serial Port  
 
8.1. Experiment with Matrix Key 8.2. Experiment with Stepping Motor 8.3. Experiment with 1-Wire Digital Thermometer DS18B20
8.4. Experiment with 24C01 EEPROM 8.5. Experiment with 93C46 Serial EEPROM 8.6. Experiment with DS1302 Real-time Clock
8.7. Experiment with 8-bit Serial AD Converter ADC0832 8.8. Experiment with 1602 Character LCD Module 8.9. Experiment with 12864 Graphic LCD
8.10. Experiment with Infra-red Remote Controller 8.11. Experiment with Wireless Encoding Module Chapter 11. User Feedback

Chapter 6. LED Display Application

7-segment LED display is widely used in consumer electronics and industrial controlling. Due to its good visibility, it is often used to display temperature, number, weight, date, time, etc.

The above picture shows the 7-segment LED displays. Each LED display consists of 7 LED segments and 1 LED decimal point.

These segments are usually named to be a, b, c, d, e, f, g, dp, as shown in the above picture.

Different segments lighting up will form different characters or numerical numbers. For example, if segment a, b, g, e, d are lighted on and segment f, c, dp off, numerical number 2 can thus be seen.

The LED displays used in KinCony 8051 MCU Development Platform are common anode. Inside LED display, all anodes of each LED are connected together, in contrast to the common cathode LED display, whose cathodes are together.

There are 8 transistors on the mainboard. These transistors control the on/off state of each LED display, shown in below picture.

In the picture, segment a, b, c, d, e, f, g, dp are connected with MCU’s P0.0 to P0.7 respectively. The base of each transistor which controls the on/off state of the 8 LED displays are connected to P2.0 to P2.7 of MCU. High or low level on transistor’s base causes LED display to light off or on.

Now, it’s time to start our experiment.

Take out the KinCony 8051 MCU Development Platform, connect it to computer via USB cable, serial cable and parallel cable. (USB cable is used to get power from computer. Serial cable is used for emulation. Parallel cable is used for ISP.) Plug the chip SST89E516 into the DIP-40 burn-in socket. (SST89E516 is offered for emulation, and AT89S51 is a blank chip for experiment.)

Now, go back to Keil uVision IDE. Create a new project named ‘led.uv2’, and choose AT89S51 as your target MCU. Upon the prompt that asks you to add startup code to the project, click ‘yes’.

Right click ‘Target 1’, and select ‘Options for Target ‘Target 1’.

In the popped dialog, select Target sheet, and set Xtal (MHz) to 11.0592.

Select ‘Output’ sheet, and select ‘Crate HEX File’.

Select ‘Debug’ sheet, and choose ‘Use: Keil Montor-51 Driver’. Then click ‘Settings’ to set proper COM port number in the popped dialog.

Click ‘File’ – ‘New...’

Type below codes in the popped text editor.

#include "reg51.h"

main()

{

while(1)

{

P0=0xa4;

P2=0;

}

}

To display numerical number 2, 0xa4 is assigned to P0. To make all 8 LED displays light up, 0 is assigned to P2, because 0, low level turn the transistor on, and that lights LED displays up as a result. while(1) causes the program flow to be in an endless loop, so that 2 is continuously displayed on all LED displays. See the below picture.

The reason to assign 0xa4 to P0, is that 0xa4 is 10100100 in binary. Each bit controls the on/off state of each segment as mentioned before. Because of the LED displays are common anode, electric current will go through common anode to each segment. A low level on each segment causes the segment to light up; therefore, we need 5 segments to be low level, and 3 segments to be high. Assign 0x80 to P0, will have the numerical number 8 to be displayed for the same reason.

The below form lists the relationship between numeric and Hex. (0 on, 1 off.)

Numeric

P0.7

P0.6

P0.5

P0.4

P0.3

P0.2

P0.1

P0.0

Hex

0

1

1

0

0

0

0

0

0

C0H

1

1

1

1

1

1

0

0

1

F9H

2

1

0

1

0

0

1

0

0

A4H

3

1

0

1

1

0

0

0

0

B0H

4

1

0

0

1

1

0

0

1

99H

5

1

0

0

1

0

0

1

0

92H

6

1

0

0

0

0

0

1

0

82H

7

1

1

1

1

1

0

0

0

F8H

8

1

0

0

0

0

0

0

0

80H

9

1

0

0

1

0

0

0

0

90H

After the emulation is successful we should disconnect the emulation connection by pressing the reset key on the development board. And then click “Start/Stop Debug Session”.

The last step is programming the MCU. For detailed programming description, flip back to “Chapter 4, In System Programming”.



COPYRIGHT2003--2008 HANGZHOU KinCony ELECTRONICS CO.,LTD. All Rights Reserved

Add:Rm 11-3-702, Pujing Jiayuan, Gongshu District, Hangzhou, Zhejiang, China.
Tel:+86-0571-87615070,Fax:+86-0571-87615070 E-mail: hificat@163.com  ICQ:164806453  Webmaster:Hificat