Design and implementation of AVR-based LED digital large screen

Publisher:HeavenlyCloudsLatest update time:2006-06-27 Source: 微计算机信息 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  1 Introduction

  LED display screen is a new information display media that developed rapidly around the world in the late 1980s and is used more and more widely. ATMEGA16L microcontroller is a low-power CMOS 8-bit microcontroller based on AVR RISC. It has 16K bytes of self-programming FLASH, 512 bytes of EEPROM, and 1K bytes of SRAM. It controls the LED display through the AVR microcontroller. It has a simple structure. , the application is flexible and easy to expand.

  2 System design principles

  2.1 Coding design

  There are two processes in coding design: font extraction and font encoding conversion. There are two font files involved in font extraction, one is ASC16, which specifically stores ASCII codes; the other is HZK16, which specifically stores Chinese character font codes. To extract the font library, you must first initialize it, that is, open the font library. Then extract its corresponding encoding based on a character. First, after taking out the internal code of the character (pay attention to distinguishing between single-byte and double-byte internal codes), then use the internal code to obtain the offset of the encoding of the font corresponding to the character in ASCII or HZK16, and finally you can use this address Find the corresponding font code at the offset position in the file. We can calculate it using this formula:

  In ASCII, offset = (low address of internal code) * 16,

  In HZK16, offset = ((high address of internal code-161)*94 + (low address of internal code-161))*32.

  The font code obtained at this time is not the final desired code (single-byte data such as English is displayed in an 8*16 dot matrix, while double-byte data such as Chinese characters is displayed in a 16*16 dot matrix). The 8*16 dot matrix is ​​used uniformly here, which requires conversion. The table on the left in the figure below shows the order in which Chinese character codes are stored in the font library, and the table on the right shows the order in which codes are stored after conversion. The encoding conversion process is shown in Figure 1:

           Figure 1 Code conversion

  2.2 Matrix conversion and shift algorithm

  
The purpose of the matrix conversion and shift algorithm is to convert these original data into serial data so that the data can be correctly input to the 74HC595. The original data must be transformed. The following is its algorithm implementation.

for(m=0; m<8; m++) //m represents the LED number

  {? for(j=0;j<8;j++) //j represents the row of data of a certain LED

  {? for(i=0; i<8; i++) //i represents the number of the row of data of a certain LED.

  { displayport_a[m][j]|=((displaycode_a[i][m]&0x01)<

      displaycode_a[i][m]=displaycode_a[i][m]>>1;

                 // displayport_a[m][j] means storing the converted data

                 // displaycode_a[i][m] means that the original data is stored

//'|' means OR, '&' means AND, '<<' means left shift

}

}

}

  2.3 Communication between the upper computer and the lower computer

  
The communication between the upper computer and the lower computer is mainly through the RS232 interface, and the data transmission rate of the upper computer is 9600bps. In order to facilitate the transmission and reception of data, flags can be added before and after the data to be transmitted. If the amount of data sent is large, threads can also be used to send data. The lower computer can use the full-duplex Universal Asynchronous Receiver Transmitter (UART) in the microcontroller to receive data.

  UART has two working modes: interrupt and query. UART initialization requires setting up several related control registers. We can express the initialization status of several UART control registers:

  UCR = 0x00 When setting the baud rate, UART must be turned off first.

  UBRR = 0x33 sets the baud rate to 9600bps

  UCR = 0xD8 Open serial port: 8-bit data

  How the UART receives and sends data is completed through the data register UDR. Although UDR has only one address, it physically separates two registers, one for sending and one for receiving. Interrupts are used to receive and send data, and the interrupt vector is 12, which is the interrupt handler uart0_rx_isr:12. The receiving and sending methods are as follows:

  Receive=UDR receives a data

  UDR= Send sends a data

  2.4 Display principle

  To light up the LED, the LED bit selection data signal must be set to low level. The display process is as follows: first, set the RCK of the 74HC595 to 0, then take out the data to be displayed and the bit selection signal from the corresponding array. Through a rising edge pulse of SCK, you can input this data into the 74HC595, and wait for all the data to be printed. After inserting the corresponding chip, finally set RCK to 1, and the data can be transmitted in parallel through 74HC595.

   3 System Design Plan

  The design of the overall hardware framework is based on the communication principle between the host computer and the lower computer, the LED dot matrix display principle and the characteristics of 74HC595. Figure 2 below illustrates the LED dot matrix display driving schematic diagram and its wiring method.


        Figure 2 LED dot matrix display driving schematic diagram

  The PA and PB ports will be used as data output ports, and a total of 16 8*8 LEDs will be connected. Each pin of the port will serve as a data input for the 74HC595. The purpose of using RCK and SCK in parallel is to achieve synchronous display of LED characters. In the line connection, Q`H must be connected to SI, because according to the characteristics of 74HC595, if the number of input data is greater than 8, then the previous data will be automatically overflowed. According to this idea, the two chips are connected and the input is entered first. 8-bit data signal, and then input the sequence of 8-bit bit selection signals, then the former 74HC595 stores the bit selection information, and the latter 74HC595 stores the data information.

  According to the design principles of the system, the software process framework shown in Figure 3 is obtained:

?


                    Figure 3 Software process framework

  4 Conclusion

  For the current display system, the advantage is that the circuit implementation is simple and the cost is low. If the system requires a larger character display library, it only needs to expand the RAM or EEPROM of the AVR and use multiple AVR microcontrollers for communication. Of course, you need to pay attention to the data writing time at this time to avoid display desynchronization.

  references

[1] Ding Huacheng, Geng Degen, Li Junkai. AVR microcontroller application design [M]. Beijing: Beihang University Press, 2002

[2] Shen Wen, Eagle lee, Zhan Weiqian. AVR microcontroller. Introductory guide to C language development [M]. Beijing: Tsinghua University Press, 2003

[3] Jin Chunlin, Qiu Huifang, Zhang Jiuxi. AVR series microcontroller---C language programming and application examples [M]. Beijing: Tsinghua University Press 2003

[4] Liu Leshan, Ouyang Xingming, Liu Xueqing. Microcomputer interface technology and application[M]. Wuhan: Huazhong University of Science and Technology Press, 2000

 
Reference address:Design and implementation of AVR-based LED digital large screen

Previous article:Applications of ultra-bright LEDs
Next article:Application of 32-channel 256-level gray high-voltage driver chip HV632

Latest Power Management 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号