Objective: Understand the working principle of LCD1602 liquid crystal
1. LCD1602 Introduction
1602 LCD is also called 1602 character LCD. It can display 2 lines of character information, and each line can display 16 characters, so it is referred to as 1602. It is a dot matrix LCD module specially used to display letters, numbers and symbols.
It is composed of several 5x7 or 5x10 dot matrix character bits. Each dot matrix character bit can be used to display a character. There is a dot spacing between each bit and there is also a spacing between each line, which serves the role of character spacing and line spacing. Because of this, it cannot display pictures well.
1602
Pin Function
VL is the LCD bias signal. If the screen is too dark or too bright, you can adjust this voltage to adjust the brightness.
RS is high level for data option, low level for command option
R/W means high level is read operation, low level is write operation
E is the enable signal
D0 ~ D7 are data I/O ports. The microcontroller can transmit data to make the LCD display different data.
BLA is the positive pole of the backlight source (A means positive), BLK is the negative pole of the backlight source (K means negative). If there is no backlight, the data is difficult to see clearly.
LCD1602 contains 80 bytes of DDRAM, which is used to store display characters.
The corresponding relationship between its address and screen is as follows:
DDRAM
DDRAM can display 80 bytes, divided into 2 rows, 40 bytes on the top and 40 bytes on the bottom, but the LCD we use has only 16 bytes in one row, and the rest is not used.
The following are the corresponding addresses, but the real address is each plus 0x80 to get our real address, such as 00 corresponding to the address 0x00 + 0x80 = 0x80
2. LCD1602 Common Commands
(1) Clear Screen Command
Clear screen command
The input command is 0x01
RS is low level is the input command
R/W low level indicates writing
Clear the LCD display, that is, fill all the contents of DDRAM with "blank" ASCII code 20H;
After clearing the screen, the cursor returns to the upper left corner of the LCD screen.
Set the address counter (AC) to 0, which is the topmost corner.
(2) Mode setting instructions
Mode Setting Instructions
Function:
Set the cursor shift direction after writing 1 bit of data each time, and set whether to move each character written.
I/D: 0 = The cursor moves to the left after writing new data; 1 = The cursor moves to the right after writing new data; usually 1, but when the cursor is at the rightmost point, the cursor moves to the left, which is like a scrolling effect
S: 0 = The display screen does not move after writing new data; 1 = The display screen moves right by 1 character after writing new data; usually 0
(3) Display switch control instructions
Display switch control
Function:
Control the display on/off, cursor on/off, and whether the cursor flashes.
D: 0 = display function off; 1 = display function on
C: 0 = no cursor; 1 = cursor
B: 0 = cursor flashing; 1 = cursor not flashing
(4) Function setting instructions
Function setting command
Function:
Set the number of data bus bits, the number of displayed lines and the font.
DL: 0 = data bus is 4 bits; 1 = data bus is 8 bits; ours is 8 bits;
N: 0 = display 1 line; 1 = display 2 lines
F: 0 = 5×7 dots/each character; 1 = 5×10 dots/each character
X: represents random value
3. LCD1602 operation steps
(1) Initialization (set the cursor above)
(2) Write command (RS=L), set display coordinates
(3) Write data (RS=H)
LCD1602 write operation timing diagram:
Timing diagram
Let's first look at the RS pin and R/W pin of the read operation timing. These two pins change first. Because it is a read operation, the R/W pin must be set to a high level first, regardless of what it was originally. Reading instructions or reading data are both read operations, and both are possible, so the RS pin may be set to a high level or a low level. Please pay attention to the drawing method in the figure. After RS and R/W change for such a long time Tsp1, the enable pin E can change from a low level to a high level.
After the enable pin E is pulled high for such a long time tD, the data output by LCD1602 DB is valid data, and we can read the data of DB. After reading, we must first pull the enable E low. After a period of time, RS, R/W and DB can change to continue to prepare for the next read and write.
The difference between the write operation timing and the read operation timing is that the write operation timing, the change of DB is completed by our microcontroller, so it must be operated before the change of the enable pin E. You can compare the other differences by yourself.
Careful students will find that there are many time labels on this timing diagram, such as the rise time tR of E, the fall time tF, the length period tC from one rising edge to the next rising edge of the enable pin E, the time interval tHD1 between the change of R/W and RS after the falling edge of enable E, and many other time requirements. How do you view these requirements?
Timing parameters
tC: refers to the shortest time from the current rising edge to the next rising edge of the enable pin E, which is 400ns. However, because our microcontroller is slow, one machine cycle is more than 1us, and a C language instruction must be one or several machine cycles, so this condition is fully met.
tPW: refers to the shortest duration of the high level of the enable pin E is 150ns. Since our microcontroller is slow, this condition is also fully met.
tR, tF: refers to the rising edge time and falling edge time of the enable pin E, which cannot exceed 25ns. This time limit has a large space. We used an oscilloscope to measure the rising and falling edge time of this pin on our development board, which is about 10ns to 15ns, which is fully met.
tSP1: refers to the enable pin E can only become a high level after the RS and R/W pins are enabled and maintained for at least 30ns. This condition is fully met.
tHD1: refers to the enable pin E can only change after it becomes a low level and remains for at least 10ns. This condition is fully met.
tD: It means that after our enable pin E becomes high, 100ns later, 1602 will send out the data, so we can read the status or data normally.
tHD2: It means that during the read operation, after the enable pin E becomes low, it must be kept for at least 20ns before the DB data bus can change. This condition is fully met. tSP2
: It means that after the DB data bus is ready, it must be kept for at least 40ns before the enable pin E can change from low to high. This condition is fully met. tHD2:
It means that during the write operation, after the pin E becomes low, it must be kept for at least 10ns before the DB data bus can change. This condition is fully met.
After reading this, do you feel that it is simpler than you thought and not as difficult as you thought? You also have to learn to read this kind of timing diagram and table slowly. In future studies, this ability is particularly important. If you switch to other types of microcontrollers in the future, then evaluate whether your program meets the timing requirements based on the execution speed of the microcontroller. Generally speaking, devices have a maximum speed limit, but no minimum speed limit, so when switching to a high-speed microcontroller, it is usually necessary to insert software delays between each step to meet the slower timing requirements.
4. LCD1602 liquid crystal interface circuit
Circuit Module
VO changes the voltage through the sliding resistor below
Previous article:Microcontroller Learning Journey for Beginners (Part 43) --- LCD12864 Liquid Crystal Display
Next article:The road to learning MCU for beginners (Part 27) --- Understanding EEPROM-IIC bus (Part 2)
Recommended ReadingLatest update time:2024-11-16 08:51
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- STM32F10 Chinese reference material
- Showing my products + my development board
- The relationship between instruction set architecture, arm core, SoC, processor, CPU, GPU, etc.
- [Raspberry Pi 4B Review] + Unboxing
- There are two types of switch circuits, such as MOS+transistor+diode+button and switch circuits with MCU IO port directly connected to the button...
- I3C standard information, sharing
- Bluetooth Low Energy GAP, GATT
- Summary of Common/Uncommon IOT Protocols
- [TI recommended course] # Strengthen power supply knowledge through the TI Power Management Lab Kit (TI-PMLK) series#
- Share: Which domestic MCU is the best?