Liquid crystal display has become the mainstream display technology in the display system of pocket electronic products due to its advantages of low power consumption, light weight, small size and ultra-thinness. It is widely used in communication, home entertainment, advertising, instrumentation and other fields. This paper designs a system that directly controls the liquid crystal display through communication between the computer and the single-chip microcomputer. Using VB software programming, an intuitive human-computer interface is designed. Characters and character movement methods are directly input through the computer keyboard, and transmitted to the single-chip microcomputer through serial communication. The single-chip microcomputer system then controls the liquid crystal display module, so that characters can be moved and displayed on the LCD screen.
1. Selection of main control chip and LCD screen
In this system, the main control chip is AT89S51 produced by Atmel. This chip has 4k bytes of programmable FLASH memory, supports serial and parallel download programs ISP online programming, and is low-priced and fast in execution. The LCD screen uses a dot matrix character LCD display module LCD162. LCD162 uses a standard 16-pin interface, can display 2 lines of 32 words, 16 ASCII characters per line, and can customize graphics. You only need to write the ASCII code of the corresponding character to display it.
2 Hardware Circuit Design
The system hardware circuit mainly consists of two parts: LCD display module and communication module. The circuit is shown in Figure 1.
Figure 1 System hardware circuit
In Figure 1, the LCD display part, the microcontroller and LCD162 use a parallel interface. The P0 port of the microcontroller is connected to the data lines D0~D7 of the LCD display, and is pulled up through 8 10 kΩ pull-up resistors. P1.5 is connected to the RS end of LCD162. When P1.5 is high, the data register is selected, and when it is low, the instruction register is selected. P1.6 is connected to RW, which is used to control the read and write operations of the LCD display. When P1.6 is high, the read operation is performed, and when it is low, the write operation is performed. P1.7 is connected to the enable end of LCD162. When E jumps from high level to low level, the LCD module executes the command.
V0 is the contrast adjustment terminal of the LCD display. A 10 kΩ potentiometer R9 provides an adjustable LCD drive voltage for V0 to adjust the display contrast.
This system needs to display the characters typed on the microcomputer keyboard on the LCD screen, so the asynchronous serial communication interface of the 51 single-chip microcomputer is used to communicate with the computer in serial, and then the single-chip microcomputer controls the LCD display module. The computer has a serial communication port RS-232, whose logic level is represented by positive and negative voltages, and the signal uses negative logic. The voltage range of logic 0 is +5~+15V, and the voltage range of logic 1 is -5~-15V. However, the output signal of the 51 single-chip microcomputer does not actually meet the RS-232 standard. The voltage on its serial communication pin is the TTL standard, that is, two states between 0~5V. Therefore, when the 51 single-chip microcomputer is connected to the MODEM, a level and logic conversion link must be inserted in the middle. Here, the MAX232 chip is used to realize the conversion task between the TTL level and the RS-232 level.
3 Software Design and Development
The software part includes the LCD display subroutine controlled by the single-chip microcomputer, the communication subroutine between the single-chip microcomputer and the PC, and the VB programming part.
3.1 LCD Display
The LCD162 liquid crystal module has a character generator CGRAM inside, which stores 160 different dot matrix character graphics. Each character has a fixed code, and its corresponding code can be found through the standard character library table. When displaying characters, you need to send the address (write command) first, and then send the character (write data). If you want to display characters outside the character library, you need to use CGRAM to compile the display. The liquid crystal display module of this system includes LCD initialization, cursor positioning, character display and other modules. Its program flow chart is shown in Figure 2.
Figure 2 LCD display control main program
During initialization, it is necessary to set the initial state, display cursor, clear screen, display mode, etc. Here, LCD162 is set to 8-bit data, 5×7 character dot matrix, and two-line display, that is, write P0 port to 38H. LCD162 has four operations: write command, read status, write data, and read data. The four operations are determined by the status of P1.5, P1.6, and P1.7. Before performing the three operations of write command, write data, and read data, you need to perform the read status operation first, and query the busy flag through the query method. When the busy flag is 0, you can perform the other three types of operations. When sending display characters, the display data needs to be written in the corresponding DDRAM address to determine the display position of the display characters. The following is the busy status judgment subroutine and the write data subroutine, and its subroutine flow is shown in Figures 3 and 4.
RS BIT P1.5
RW BIT P1.6
E BIT P1.7
LCD EQU P0
; Determine whether the subroutine is busy:
CHECK_BF:
MOV LCD,#0FFH
CLR RS; When RS is low and RW is high, the status can be read
SETB RW ; RW=1, select read mode
CLR E
NOP
SETB E ;E=1, allows reading/writing LCD
NOP
JB LCD.7,CHECK_BF
RET
;Write data subroutine:
WR_DATA:
SETB RS; RS = 1, select data register
CLR R
CLR E
ACALL CHECK_BF
MOV LCD, A; send data to P0,
NOP; Give the hardware time to react
NOP
NOP
NOP
SETB E
NOP
NOP
NOP
NOP
CLR E ; When E changes from 1 to 0, the LCD module starts
Execute Command
RET
Figure 3 Busy judgment subroutine
Figure 4: Write data subroutine
3.2 Serial communication between MCU and PC
The serial data transmitting terminal TXD and the serial data receiving terminal RXD of the single-chip microcomputer are connected to T1 and R1 of MAX232 respectively. The settings should correspond to the serial port settings of the PC. The serial port of the single-chip microcomputer in this system adopts working mode 1, and the baud rate is set to 9600, which is generated by timer T1. At the beginning of communication, the PC sends a handshake signal. After receiving the handshake signal, the single-chip microcomputer sends a response signal back to the PC. After the PC receives the response signal and verifies that it is correct, it means that the serial port communication is successful.
3.3 PC Serial Communication
The computer communication is written in VB6.0 software. There is a MSComm communication control in VB, which can set the sending and receiving of serial communication data. By programming the properties and events of this control, serial communication can be easily realized. The MScomm control provides two communication methods: event-driven and query mode. This system uses the query mode to process communication. In order to ensure reliable communication between the computer and the single-chip microcomputer, both parties need to set the same data format and baud rate. This system uses binary to send and receive data. Before sending data, the sending buffer needs to be cleared, that is, the OutBufferCount property value of the MScomm control is 0. When initializing the communication port, select the serial communication port Com1, set its baud rate to 9600, no parity check, 8-bit data transmission, and 1 stop bit. After the character data is sent, use the Enter key as the end.
The following program is the code to realize communication, where Label1 control is used as the prompt label when serial communication is successful.
Private Sub MSComm1_OnComm()' Serial port settings
Dim Buffer As Variant
Dim Hexbuffer() As Byte
If MSComm1.PortOpen = True Then
Select Case MSComm1.CommEvent
Case comEvReceive 'A receive event occurs
MSComm1.InputLen = 0
MSComm1.InputMode = comInputModeBinary
'Data transmission and reception adopt binary
Buffer = MSComm1.Input
Label1.Caption = Buffer
Hexbuffer() = Buffer
Dim I As Integer
For I = 0 To UBound(Hexbuffer)
If Hex(Hexbuffer(I)) = 1 Then
Label1.Caption = Label1.Caption & "0" &Hex(Hexbuffer(I))
Else
Label1.Caption = Label1.Caption & Hex(Hexbuffer(I))
End If
Next I
End Select
End If
End Sub
Two buttons for moving left and right are also set in the VB form interface. By adding two timers, timer1 and timer2, and changing the position property of the control in the timer event, the characters can be moved on the form. Figure 5 shows the simulation effect through the virtual serial port and Proteus software. In Figure 5, the left picture is the VB form interface, and the right picture is the LCD display simulation picture. Enter characters in the form text box control, click the send button to display them on the LCD screen, and click the left and right buttons to move the contents of the LCD screen at the same time.
Figure 5 VB controlled LCD display simulation
4 Conclusion
This system uses a computer as the host and a single-chip microcomputer as the slave, realizing serial communication between the computer and the single-chip microcomputer, and can input characters into the computer through the keyboard and display them on the LCD screen. The system structure is simple and has certain practicality.
Previous article:Photoelectric detection system with weak light signal preamplifier circuit
Next article:Implementation strategy of street lamp control and management system based on GIS
Recommended ReadingLatest update time:2024-11-17 01:41
- Popular Resources
- Popular amplifiers
- Virtualization Technology Practice Guide - High-efficiency and low-cost solutions for small and medium-sized enterprises (Wang Chunhai)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Raspberry Pi Development in Action (2nd Edition) ([UK] Simon Monk)
- VB Tutorial HD
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- Creating music with PICO
- Play with "ultra-energy-saving, high-precision, machine learning core" motion sensors [ST MEMS sensor competition]
- Ultra-wideband (UWB) working principle, origin and current status
- Using PLLs in Cyclone Devices
- 1uS wide pulse signal
- The test method of Tg value and the factors affecting it
- [Qinheng Trial] CH559EVT Trial 1: Unboxing and First Look
- Transfer idle STM32 development boards, etc.
- EEWORLD University ---- How does high voltage isolation technology work - Capacitor structure
- [RVB2601 Creative Application Development] 3. WiFi network communication