Control design of LED dot matrix display screen using AT89S52 microcontroller

Publisher:beta13Latest update time:2023-07-17 Source: elecfansKeywords:AT89S52 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Chapter 1 Overview

The LED dot matrix display screen extracts the Chinese character fonts to be displayed through a PC and sends them to the microcontroller, and then displays them on the dot matrix screen. It is mainly suitable for indoor and outdoor Chinese character display.


Chapter 2 Hardware Design

2.1 Introduction to main components

The LED dot matrix display is composed of 20 8*8 LED dot matrix blocks, forming a 16*80 rectangular dot matrix, with Atmel's AT89S52 microcontroller as the control core. Other main hardware of the display screen are: ① 8-bit shift register 74HC595 with latch output, used as LED column line driver input; ② Sanba decoder 74LS138, used as LED row line decoding selection; ③ Transistor C9012, Connect the sixteen output terminals of two three-eight decoders and use them as switches to drive row lines of LEDs.


2.2 Detailed connection instructions of main components

Control design of LED dot matrix display screen using AT89S52 microcontroller

The pins connected to Atmel's AT89S52 chip-related devices are as follows: P00-P03 are connected to the input ports A, B, C, and ~G2A of the 3-8 decoder.

Control design of LED dot matrix display screen using AT89S52 microcontroller

P20-P23 connect the input ports RCK, SI, SCK, SCLR of 74HC595

The 16 output terminals of the 38 decoder 74LS138 are connected to the base B of 16 C9012 transistors, the emitter E is connected to the 16 row line control terminals, and the collector C is connected to GND.

The 80-column data line driver of the dot matrix is ​​composed of 10 74HC595 cascades. The Q'H pin of the previous 74HC595 is connected

The SI pin of the next piece, and the RCK, SCK, and SCLR of each piece are connected in parallel.

2.3 LED lattice block

The 8*8 LED dot matrix is ​​a single-color row common anode module. The working voltage of a single point is forward (Vf) = 1.8 v, and the forward current (IF) = 8-10 mA. When the device is lit statically (64 points are fully lit), the total current is 640mA, the total voltage is 1.8V, and the total power is 1.15W. When dynamic, depending on the scanning frequency (1/8 or 1/16 seconds), the instantaneous current at a single point can reach 80-160 mA. The 16*16 dot matrix has a static current of 16*16*10mA and a single point current of 80-160mA dynamically.

Wiring:

When a certain row line is high and a certain column line is low, the intersection point of its row and column is lit;

When a certain column line is high, the point where its rows and columns intersect is dark;

When a certain row line is set low, all points corresponding to this row will be dark regardless of the column line.

Control design of LED dot matrix display screen using AT89S52 microcontroller

Column lines: 13-20 control dot matrix columns connected to low level

Row lines: 1-4 21-24 control the rows of the dot matrix connected to high level

2.4 AT89S52

Control design of LED dot matrix display screen using AT89S52 microcontroller

Control design of LED dot matrix display screen using AT89S52 microcontroller

(1) P0.0 [39 pin], P0.1 [38 pin], P0.2 [37 pin], P0.3 [36 pin] are connected to A, B, C and two 3-8 decoders. The ~G2A of the first piece and the G1 of the second piece are used to select the LED row lines.

(2) P2.0 [21 pin]: Connect to the RCK pin of 74HC595.

P2.1 [22 pin]: Connect to the SCK pin of 74HC595.

P2.2 [23 pin]: Connect to the SI pin of 74HC595.

P2.3 [24 pin]: Connect to the SCLR pin of 74HC595.

(3) Others

VCC [40 pin]: connect to power supply

EA/VPP [31 pin]: connect to power supply

RST [pin 9]: reset pin. Connect the 10K resistor to GND, connect the 10uF capacitor C3 to VCC; connect the reset button to both ends of the capacitor C2.

2.5 Shift register 74HC595

74HC595 is an 8-bit shift register with latch output. Its pins are shown in the figure below, where SI is the input terminal of serial data;

VCC and GND are power supply and ground respectively; RCK is the input clock of the storage register, SCK is the input clock of the shift register, SCLR is the input clear of the shift register, Q'H is the output of the serial data, and G is the input data Output enable control, parallel output of QA~QH serial input data. The data input from the SI port is moving

Control design of LED dot matrix display screen using AT89S52 microcontroller

The bit register is input to the 74HC595 under the action of the rising edge of the SCK pin. The input data is latched in the 74HC595 under the action of the rising edge of the RCK pin. When G is low level, the data is output in parallel. SCLR is the input clear terminal of the shift register.

The connection between 74HC595 and AT89S52: SI [pin 14], SCK [pin 11], RCK [pin 12], SCLR [pin 10] are connected to P2.2 [pin 23] and P2.1 [pin 22] of AT89S52 respectively. P2.0 [21 feet], P2.3 [24 feet] on.

Other pin connections: OE [pin 13] is grounded so that it always outputs;

Q'H [pin 9] is the SI pin connected to the next 74HC595; QA, QB to QH are connected to the column pins of columns 1 to 8 of the LED dot matrix respectively.

2.6 38 decoder 74LS138

Control design of LED dot matrix display screen using AT89S52 microcontroller

The figure shows the connection diagram of extending two 74LS138 decoders into a 4-line to 16-line decoder. Its wiring characteristics are: connect the lower three bits C, B, and A of the four input signals ~G2A, C, B, and A to the address input terminals of the two chips at the same time. The highest bit of the input signal ~G2A is connected to the enable terminals of the two chips so that the two chips cannot work at the same time. ~G2A, C, B, A are used as address input variables to form a binary code, Y0~Y7, Y0~Y7 are used as input signals, each output represents the meaning of a binary code, that is, the function of a 4-line to 16-line decoder can be realized .

Chapter 3 Software Design

3.1 Programming of microcontroller

In the LED dot matrix display system, the microcontroller is mainly responsible for the three main functions of data reception, storage and scanning and display of the LED dot matrix screen.

/****************************************************** ***************************************************

* Name: khldragon

*Date: 09/12/2009

* Description: This program controls 16*80LED and implements dynamic scan.

*************************************************** *************************************************** /

#include

#include

#define CONIO P0 //row selection signal

#define NUMOFWORDS (6) //Number of words displayed

#define SPEED (30) //The larger the scan period SPEED, the slower the scan;

#define MAXWORDS (5) //Maximum fixed number of words displayed on the screen

#define BLANK (4) //Fill in blank numbers

#define MAXROW (16) //Maximum number of rows

static sbit OE = P0^4; //Control 74LS138, active low level

static sbit RCK = P2^0; // Data output on rising edge

static sbit SCK = P2^1; //Data shift on rising edge

static sbit SI = P2^2; //74hc595 serial input

static sbit SCLK = P2^3; //The low-level shift register is cleared, usually connected to VCC

static void send_in(unsigned char Data); //Serial data input

static void send_out(void); //Parallel data output

static unsigned int row = 0; //Row selection signal

static int j = 0;

static int k = 0;

static int m = 0;

static int s = 0; //match SPEED

static int count = 0; //When it is 5, the maximum number of words MAX is reached

const static unsigned char code zimo[][32]={

{0x20, 0x08, 0x13, 0xFC, 0x12, 0x08, 0x02, 0x08, 0xFE, 0x08, 0x0A, 0x08, 0x12, 0x08, 0x3B, 0xF8,

0x56, 0xA8, 0x90, 0xA0, 0x10, 0xA0, 0x11, 0x20, 0x11, 0x22, 0x12, 0x22, 0x14, 0x1E, 0x18, 0x00}, //Congratulations

{0x00, 0x80, 0x20, 0x80, 0x20, 0x80, 0x20, 0x80, 0x20, 0x88, 0x24, 0x98, 0x3E, 0xA0, 0x20, 0xC0,

0x20, 0x80, 0x20, 0x80, 0x20, 0x80, 0x20, 0x82, 0x26, 0x82, 0x38, 0x82, 0x60, 0x7E, 0x00, 0x00}, // Ratio

{0x01, 0x00, 0x7F, 0xFE, 0x44, 0x42, 0x9F, 0xF4, 0x04, 0x40, 0x1F, 0xF0, 0x04, 0x40, 0x7F, 0xFC,

0x08, 0x20, 0x1F, 0xF0, 0x28, 0x2E, 0xC9, 0x24, 0x09, 0x20, 0x01, 0x00, 0x06, 0xC0, 0x18, 0x30}, //race

{0x00, 0x80, 0x00, 0xA0, 0x00, 0x90, 0x3F, 0xFC, 0x20, 0x80, 0x20, 0x80, 0x20, 0x84, 0x3E, 0x44,

0x22, 0x48, 0x22, 0x48, 0x22, 0x30, 0x2A, 0x20, 0x24, 0x62, 0x40, 0x92, 0x81, 0x0A, 0x00, 0x06}, // into

{0x00, 0x80, 0x00, 0x80, 0x08, 0x80, 0xFC, 0x80, 0x10, 0x84, 0x17, 0xFE, 0x10, 0x84, 0x10, 0x84,

0x10, 0x84, 0x10, 0x84, 0x1D, 0x04, 0xF1, 0x04, 0x41, 0x04, 0x02, 0x44, 0x04, 0x28, 0x08, 0x10}, //Function

{0x00, 0x00, 0x01, 0x80, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x01, 0x80,

0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x03, 0xC0, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00}, //!

};

void main()

{

//Initialize pin

CONIO = 0X00;

P2 = 0X08;

/************************************Dynamic scan left shift display unlimited number of words************ *********************************/

while(1)

{

for(k = 0; k < NUMOFWORDS; k++)

{//Scan NUMOFWRODS times

for (s = 0; s < SPEED; s++)

{

for (row = 0; row < MAXROW; row++)

{

count = 0;

//Send the word to be displayed to the SI terminal of 74HC595, which is the P2^2 pin of the microcontroller

for (j = k; j 》= 0; j--)

{

count++;

if(count》MAXWORDS)

break;

send_in(zimo[j][2*row+1]);

send_in(zimo[j][2*row]);

}

//Fill in the blanks

for (m = BLANK-k; m 》 0; m--)

{

send_in(0);

send_in(0);

}

send_out();

CONIO=row;

}

}

}

//The following program logic is the same as above, just change the position

for(k = 1; k «= MAXWORDS; k++)

{

for (s = 0; s < SPEED; s++)

{

for (row = 0; row < MAXROW; row++)

{

for (m = k; m 》 0; m--)

{

send_in(0);

send_in(0);

}

for (j = 1; j «= MAXWORDS - k; j++)

{

send_in(zimo[NUMOFWORDS-j][2*row+1]);

send_in(zimo[NUMOFWORDS-j][2*row]);

}

send_out();

CONIO=row;

}

}

}

}

}

/****************************************************** ****************

** Function name: void send_in (unsigned char data)

** Input: unsigned char data

** Output: void

** Function description: send data to 74hc595

** Global variable: SCK SI

** Call module: main()

** Author: khldragon

** Date: 09/12/2009

** Version version1.0

*************************************************** ******************/

void send_in(unsigned char data)

{

unsigned char i;

for(i = 0; i < 8; i++)

{ //Loop 8 times, exactly 8 bits have been moved

SCK = 0; //Set the shift register control pin low first

SI = Data & 0x01; //Get the lowest bit of data, form: little endian

Data 》》= 1; //Move the second highest bit of data to the highest bit

SCK = 1; //Set it high again to generate the rising edge of the shift clock. The data in the data register is shifted on the rising edge.

_nop_();

}

}

/****************************************************** ****************

** Function name: void send_out (void)

** Input: void

[1] [2]
Keywords:AT89S52 Reference address:Control design of LED dot matrix display screen using AT89S52 microcontroller

Previous article:Design of intelligent thermostat using 51 microcontroller
Next article:How to use a microcontroller to make a manual counter

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号