introductionWith the development and improvement of LED technology, large LED displays have been widely used in various public places to display multimedia information such as text, graphics, video images and so on. In the construction of urban information modernization, LED display screen has become one of the important media of modern information dissemination. With the sharp increase in the number of outdoor LED screens and the expansion of the scope of use, new requirements are put forward for the management and control of LED displays.1. System working principle
The system is mainly composed of upper computer and lower computer. The upper computer is a device installed with LED screen management software and can connect to Internet or GPRS network, such as PC, mobile device, etc. The lower computer is the LED screen wireless controller based on AVR MCU control module. The system topology is shown in Figure 1.The system mainly uses GPRS module as wireless modem to realize the dial-up Internet access of LED display wireless controller (as client), TCP wireless communication with upper computer (as server) on Internet network, data transmission and wireless data update of LED screen.2. Hardware design of lower computer
As shown in Figure 2, the wireless controller of LED screen is mainly composed of four parts: power supply module, GPRS module, AVR single chip microcomputer control module and LED display screen.2.1 AVR single chip microcomputer control moduleIn order to ensure the real-time and efficiency of communication data and drive LED display screen, the MCU used in this module is Atmega 162 of ATMEL company with dual serial port. It is an 8-bit single chip microcomputer with low-power CMOS based on avrrisc. It has very high stability and reliability, can adapt to various environments and is suitable for various wireless LED display screen environments.
This module mainly processes the information received by GPRS module, transmits the received screen display information to LED screen, and sends at command through serial port to monitor whether GPRS module has new messages. Once there is, it immediately enters the serial port interrupt to process the data. Under the TCP / IP protocol, the data is transmitted in hexadecimal mode without Chinese character decoding, which greatly simplifies the design of the peripheral circuit of the system.2.2 GPRS module circuitThe GPRS module adopts SIM300 of simcom company. The module has small volume and outstanding performance. It can be widely used in wireless voice transmission, on-board system, remote meter reading, safety monitoring, remote control and telemetry, handheld devices and other fields.
SIM300 module has a fully functional system interface, integrates TCP / IP protocol stack internally, expands TCP / IP at instructions, and can interoperate the at instructions provided by it through serial port. This can reduce the difficulty of development, easy to realize data transmission, low cost and good scalability of the system.The SIM300 needs an external SIM card holder, and its serial port is connected with the serial port of the single chip microcomputer to transmit the information received by the GPRS module to the single chip microcomputer for data processing. The AVR single chip microcomputer controls the switch of SIM300 module. The connection diagram between AVR single chip microcomputer and SIM300 module is shown in Figure 3.2.3 LED screen driving circuit
The classic 74HC595 is used as the column driver of dot matrix output, and ULN2803 is used as the row driver. The driving circuit design of this scheme has simple software and hardware design, low power consumption, strong driving ability and less I / O port lines. It is a design scheme with low cost and flexible application.3. Communication protocol designBecause the system adopts the communication mode of GPRS network, the upper computer sets up an LED controller management platform to manage all led controllers. The LED controller management platform (i.e. "host computer software") communicates with the LED screen wireless controller through TCP / IP protocol, and can control multiple devices at the same time. The upper computer software and the LED screen wireless controller are connected by GPRS, and the connection relationship between them is shown in Figure 4.
The LED screen wireless controller is the client, and its data sending and receiving is controlled by the upper computer software. When the LED screen controller is powered on and running, it will actively establish a connection to the upper computer software and shake hands. After successful login, the upper computer software and LED controller can transmit data.The communication protocol between the upper computer software and each LED screen wireless controller is based on TCP protocol, and an STCP protocol layer is customized to encapsulate the PDU (data unit) data layer protocol. STCP protocol layer only provides a safe and reliable transmission process for the bearing framework of PDU. The structure diagram of communication network layer is shown in Figure 5.Fig. 5 structure diagram of communication network layer
In the customized STCP communication protocol, a series of communication instructions for managing the wireless LED display controller are formulated, which mainly provides specific communication structure and specification for the programming of host computer software. The format of communication packet is shown in Table 1:Table 1 format of communication packetNote:
Complete data length: integer bytes (4 bytes in length), the length of the entire communication packet;Command word: according to the communication command table of wireless LED display controller, see Table 2;Explicit control word: 0-none; 1 - move up; 2 - move down; 3 - left shift; 4 - shift right; 5 - stationary; 6 - flashing; 7 - delete;
Data content: information content to be displayed;Checksum: cumulative checksum of all data;According to the actual application needs of wireless LED display controller, the instructions of sending, deleting, displaying, connecting and disconnecting are formulated. The codes and main functions of these instructions are shown in Table 2.
Table 2 communication instructionsAfter the upper computer software sends the data to the wireless LED display controller through the Internet network, the LED display controller needs to process the received data. According to different instructions, the display content and display mode of LED display screen can be controlled (such as moving up, moving down, moving left, moving right, stationary, flashing, deleting, etc.).4. Software design
The software design of the system includes two parts: the upper computer software and the control program of AVR single chip microcomputer. The upper computer software completes the communication with GPRS module and controls the data information displayed on LED display screen; The control software of AVR single chip microcomputer mainly completes system initialization, GPRS network connection, receives the information sent by the upper computer, analyzes the content of the received information, completes the instructions, converts the released information into dot matrix information as needed, and sends it to the LED display screen for display.4.1 control program of AVR single chip microcomputerThe control program of AVR MCU mainly completes the following functions: connecting GPRS network, data transmission, controlling LED screen display.
(1) Initialize the system and SIM300 module and connect to GPRS network; (2) According to the communication protocol between the display controller and the host computer, communicate with the host computer, shake hands, receive instructions, analyze instructions, and store and process display data and other information; (3) The LED screen is driven through the serial port to display information, etc.The following briefly introduces the TCP / IP wireless communication process between SIM300 module and host computer.At cgdcont = 1, "IP", "cmnet" -- register China Mobile Network
OKATCGCLASS -- Displays the type of GPRS message movementCGCLASS B
OKATCGATT -- GPRS service attach / detachCGATT 1
OKAt cgact = 1, 1 -- environment activationOK
At cipstart = "TCP", "220.127.116.11", "2020" -- startTCP connection (upper computer IP address and port number)OK
Connect OK -- connection successfulAt cipend -- send data over TCP》 HELLO
Send OK -- send succeeded4.2 upper computer softwareThe upper computer software of the system mainly uses VC to design a communication interface to communicate with LED remote controller. The user interface part adopts MFC framework and is implemented based on dialog. When using Visual C to develop the network transmission of data through TCP / IP protocol, the IOCP framework is used to realize the completion port model of windows socket.
IOCP, I / O completion port, is an asynchronous I / O API that can efficiently notify applications of I / O events. After a socket is created, it is associated with a completion port. When an event occurs, the completion port will be added to a queue by the operating system, and then the application can query the core layer to get the completion port. Once an I / O operation is completed, a worker thread that can process the result of the operation will receive a notification. Create a number of worker threads in this application to handle notifications of overlapping I / O requests.
The startup process of IOCP framework is shown in Figure 6.The implementation steps of IOCP framework are as follows:(1) Initialize the Winsock working environment, create the completion port, create the completion port thread, and establish a listening socket to associate the socket with the completion port;
(2) The listening socket starts working. When the listening socket receives the connection request from the client TCP, the IOCP will obtain and process the message, create the corresponding socket object for receiving and processing, and complete the connection;(3) After the client completes the TCP connection, it can start data communication. The I / O thread is responsible for distributing I / O requests and allocating the logical processing environment through the thread pool;(4) After receiving the data, an I / O data structure (wsaoverlapped) provided by Microsoft is extended to complete protocol analysis and data processing.
In addition, the thread pool here is just a management queue, which is used to manage thread resources and complete the processing of maximum business logic with the least threads. The real thread function does not complete the detailed business processing, but only completes the re call of I / O request, and the virtual function realizes the re processing of I / O request.In order to improve the friendliness of the software, the framework uses the message mechanism of windows to interact with the UI, and transmits the relevant information of the framework to the UI window through the window message. Therefore, a pointer member is reserved in the framework, and the message response function is called through the pointer to send a message to the window when necessary. The UI reflects the operation information of the framework according to the message.5. Conclusion
Bao’an District Shenzhen City, China
+86 189 3806 5764