Revolutionary progress in bringing the computer to infiltrate all sectors, the traditional definition of a computer major changes have taken place. Microcontroller called Micro-Controller/Embedded-Controller, its high cost and highly industrial control, consumer electronics field attention. Microcontroller Serial communication is used in many systems integration approach. In some complex control systems, microcontroller and PC machines connected into a system solution. Microcontroller and PC, Internet, PC, a powerful use of computing decision-making capacity, the microcontroller as a special environment for data acquisition and execution units, are increasingly being used to the industrial control field, which can greatly save system cost.
2 Total Solution
MCU selection Atmel89S52, through DB9 serial cable to the computer using RS232 serial communication standard. The communication between the microcontroller and the computer a certain communication protocol. Serial communication through the computer terminal on a single chip software control the display of the content and LCM display. Send string or text file to the microcontroller, Microprocessor LCM, and received on the content displayed on the LCM (LCM can display only ASCII characters and 8 custom characters), through the PC-side software can control characters are displayed, such as scroll, wrap, for screen display, and you can read the current LCM display. Therefore, the basic component is the SCM system, PC-side serial port communication software.
As computing power is stronger than PC-SCM, so to handle the data pre sent again MCU. MCU provides a buffer of limited capacity, PC-side software to send the content to display buffer can be read from the buffer contents are displayed. PC-Serial communication software written using JAVA, JAVA language is characterized by a high degree of portability, another JDK (JAVA Development Kits) provides a rich class library, can easily construct a good graphical user interface (GUI) applications .
3 System Design and Implementation of hardware
Hardware circuit consists of power circuit, the microcontroller power-on reset and oscillator circuit, microcontroller, and data path between the LCM, the other is between the microcontroller and PC, RS232 communication module design, the use of MAX232 chips, is responsible for converting the signal level.
.3.1 Power supply design
Shown in Figure 1, the power supply circuit, rectifier bridge built, so you can enter the DC or AC 9V power supply, and then stabilize by 7805 to 5V for the microcontroller work. Three-terminal power supply fixed by the output pin 7805 is Vo, the input pin and ground pin GND Vi composition, it is the regulator +5 V, it belongs to CW78XX series regulator, the input termination capacitor can be further filtered output capacitor can also take the moment to improve the impact of the load, the circuit stability is relatively good, but with the capacitor must be smaller leakage current of tantalum capacitors, if the use of electrolytic capacitors, the capacitance value than others to increased by 10 times.
3.2 SCM and LCM external circuit drive circuit
The minimum system consists of single chip oscillator circuit, reset circuit. Part of the system clock is implemented using the crystal oscillator. Taking into account the input power supply ripple effect on the microcontroller, an increase in the power supply pins to achieve a capacitor filter, a smaller input disruption. In this system, the crystal used in 11.0592Mhz by the 10K resistor and 10uF capacitor reset circuit composition. -EA/Vpp Then VCC, because access to the internal memory .ALE /-PROG should be empty. SCM P0 and P2 ports and RT1602 LCM connection. The purpose is to facilitate the use of 11.0592MHz serial use 9600bit / s communication speed.
lcd display moduleis a kind of liquid crystal displays, connectors, integrated circuit, PCB circuit board, backlight, the structure of the components assembled together, in fact, it is a commercial component. The design uses 1602 series of dot matrix character LCD module, each line can display 16 characters, 2 lines. It is a dot matrix character LCD display and a dedicated line, column driver, controller and the necessary connectors, assembled structure, and can display digital and Western character. The dot character itself has a character generator module, display capacity, feature-rich.
3.3 RS232 serial communication circuit
This system is mainly serial communication module to communicate with the host computer. SCM system will save the data in RAM to the host computer for processing, thereby reducing the burden of SCM system. The microcontroller to communicate with the host computer interface, different levels, hence the need for the interface conversion, where the interface using MAX232 chip to achieve the level of transformation.
4 Communication Protocol
Microcontroller and PC-side software to communicate to the communication must comply with certain rules, such as, MCU initiative to send the initialization code to the PC-side successful, PC sends a specific code that will send the data to the MCU, MCU do Receive preparation.
RS232 communication speed up to 19200bit / s. The software used 9600bit / s communication speed. Communication protocol should be as short as possible so as to improve communication efficiency.
5 System Software Design
System software design, including microcontroller and the PC-side in two parts. Microcontroller through the serial port side is mainly the information received from the host computer, and then the information will be displayed in the LCM. PC-side software through the preparation of some of the major graphical interface, to achieve the users control the entire system.
5.1 SCM-side software
SCM-side software written by C51 (C-code), using Keil uVision integrated development environment. SCM client to complete the initialization of the main, LCM display, serial communication.
Initialization of the microcontroller MCU is mainly open and LCM serial port interrupt the initialization display. To set the following registers: IE, EA, ES, SCON, PCON, TCON and so on.
LCM display complete control over the display of the main contents and forms, and receive and send information to the PC, and in the display must first read its busy marker to determine whether it can accept data display module .
MCU part of the serial communication module to complete as long as the communication between PC and SCM, which will send the required information system to the host computer for processing. The AT89S52 microcontroller with on-chip UART, serial communication therefore relatively easy to achieve, just set the appropriate registers to enable the serial port to work. Serial communication with cycle (query) and interrupt two ways. On the use of efficiency, the interrupt mode to save CPU resources than the query. Therefore, the serial communication with the microcontroller interrupt to receive and send data.
5.2 PC-side software
PC-side software is mainly responsible for providing a convenient user interface to send and receive, and handle the serial port information. This software is running, to initialize the user interface using the main thread, and start a background thread is responsible for monitoring the user to select the serial port has to accept the information sent by the microcontroller, and in a timely manner displayed. When a user enters the characters to be sent, click Send, can send data to the serial port and timely addition, a complete software to help is also essential, so user-friendly software.
System needs to summarize the class object: the user interface class MainFrame, serial class PortControl, serial write data class SerialWriter, serial read data class SerialReader.
PC-side during the serial communication programming, must be used before the first resource request made to the operating system requirements (open serial port), and then configure the port parameters, then we can exchange data with the serial port and complete data from the serial port to send and receive . Finally, completion of the release of the communication resources (close serial port). Create the serial port class PortControl, responsible for the serial port enumeration, data transmission and data reception.
Innovation of this paper is the design of the serial communication software using JAVA language, the successful solution of the bottom part of the system resources because the serial port, most closely integrated with the system, in order to develop cross-platform software, the problem is difficult to achieve, through the different system customized to the different JAVA VM to provide a unified interface; followed by selection of the design of dot matrix character LCD module 1602 series, which has the character dot matrix character generator module itself, displayed large capacity, feature-rich; Finally, the PC software programming interface for the control of LCM , thereby avoiding the LCM display by changing the source code to change the function. Since the first year of implementation of the project, and create economic benefits over 68 million.