LCD display principle
Liquid crystal is a polymer material. Due to its special physical, chemical and optical properties, it has been widely used in thin and light displays since the mid-20th century.
The main principle of Liquid Crystal Display (LCD) is to use electric current to stimulate liquid crystal molecules to produce points, lines, and surfaces which in conjunction with the back light tubes form a picture.
Now let's understand the physical properties of liquid crystal: LCD itself cannot emit light, it needs the help of light source to display, which is what we usually call backlight. When the light beam passes through this layer of liquid crystal, the liquid crystal itself will stand up in a row or twist into an irregular shape, thus blocking or allowing the light beam to pass smoothly.
Most liquid crystals are organic compounds made of long rod-shaped molecules. In their natural state, the long axes of these rod-shaped molecules are roughly parallel. When liquid crystal is poured into a well-machined grooved surface, the liquid crystal molecules will align along the grooves, so if the grooves are perfectly parallel, the molecules will also be perfectly parallel.
That is to say, if the molecules on one plane are arranged in a north-south direction, the molecules on the other plane are arranged in an east-west direction, and the molecules between the two planes are forced into a 90-degree twisted state. Since light propagates along the direction of the molecular arrangement, the light is also twisted 90 degrees when passing through the liquid crystal. But when a voltage is applied to the liquid crystal, the molecules will rearrange vertically, allowing the light to be emitted directly without any twisting.
A polarizing filter is actually a series of increasingly thin parallel wires. These wires form a web that blocks all light that is not parallel to them. The wires of the polarizing filter are perpendicular to the first, so they completely block light that has already been polarized. Light can only pass through if the wires of the two filters are completely parallel, or if the light itself has been twisted to match the second polarizing filter.
Therefore, by applying voltage through these polarizers in specific directions, light can be allowed to pass through some areas, while light is blocked in other areas. The image of these alternating light and dark points arranged in certain pixels is the information we want to display.
The 1602 LCD display module contains a driver chip HD44780 (HITACHI) or other compatible chips, and provides a library of 192 characters that users can call directly. It can display two lines of characters, each line includes 16 display character blocks composed of 5×8 dot matrix blocks, each dot matrix block is a character position, and the character spacing and line spacing are both the width of one dot.
Next Steps
LCD1602 display control
After understanding the LCD display principle, how can we make it display characters? To do this, we must first understand the characteristics and control methods of its internal driver chip. The microcontroller controls the display driver and also needs to communicate. Here we have to mention the timing that we have been emphasizing before. In the previous section, when we explained UART, we knew that UART communication has strict timing requirements, so it requires precise baud rate control. Although the LCD control timing does not need to be as precise as UART, it also requires certain requirements. Let's first take a look at its common interfaces and pin descriptions.
●VSS: Power ground pin.
●VDD: power supply pin.
●Vo: LCD display bias signal pin, apply 0 ~ 5V voltage to adjust the display contrast.
●RS: Register selection pin, when it is high level, it selects the data register; when it is low level, it selects the instruction register.
●R/W: Read and write operation selection pin, high level is read operation; low level is write operation.
●E: Enable signal pin, low level is valid.
●DB0 ~ DB7: Data bus pins, used to input data to drive the 1602 LCD module display.
●A: Backlight 5V power pin.
●K: Backlight ground signal pin.
Now let's understand its control timing:
As can be seen from the figure, the timing changes of the three control pins RS, R/W, and E in its read and write operations are different. And there are also differences between data and instructions, so it can be specifically divided into the following four situations:
Read status - input: RS=L, R/W=H, E=H; output: D0~D7=status word.
Read data - Input: RS=H, R/W=H, E=H; Output: None.
Write instruction - input: RS=L, R/W=L, E=H, D0~D7=instruction code, E=H; output: D0~D7=data.
Write data - Input: RS=H, R/W=L, E=H, D0~D7=data, E=H; Output: None.
The display's internal driver chip has an 80-byte RAM buffer, and its addresses correspond to the following:
But we know that the display interface can only display 16*2 characters at most, so how does it handle all the buffers internally?
When writing display data to any of the addresses 00H~0FH and 40H~4FH in the figure, the LCD can display it immediately; but when writing to addresses 10H~27H or 50H~67H, they must be moved into the displayable area through screen shift instructions for normal display.
The built-in string distribution table of the display is as follows:
The control instructions of the display driver are as follows:
There is a lot of information above, and some of it is not fully listed, so I will not list it here one by one. You don’t need to memorize it when using it, just refer to the information to program.
LCD1602 Display Example
The above introduces the main contents related to the 1602 LCD display. Now let's draw a simple circuit diagram and then program and test it.
In this circuit, we connect the display data port to P0, and the other three control pins to P2.2~P2.4.
Now let's program it to display some simple characters:
/*
* This is a LCD1602 display program
*The purpose is to display some characters on the display
*/
#include
#include
#define DB1602 P0 //1602 data port
typedef unsigned char u8;
typedef unsigned int u16;
sbit rs_1602=P2^2;
sbit rw_1602=P2^3;
sbit en_1602=P2^4;
void delay(u8 ms);
void lcd1602_check_busy();
void Write_Byte_1602(u8 Byte,bit dat);
void lcd1602_Init();
void Write_char1_1602(bit x,u8 y,u8 dat1);
void Write_string_1602(bit x,u8 y,u8 *str);
void main(void)
{
lcd1602_Init();
Write_string_1602(0,0," Hello guy!");
Write_char1_1602(1,6,'-');
Write_string_1602(1,7,"--LCD1602");
while(1)
{
}
}
void delay(u8 ms)
{
u8 i,j;
for(i=0; i
{
for(j=0; j<110; j++)
{
;
}
}
}
void lcd1602_check_busy()
{
u8 busy;
bit via;
do
{
rs_1602=0;
rw_1602=1;
DB1602|=0xf0;
en_1602=1;
busy=DB1602;
en_1602=0;
en_1602=1; //
en_1602=0; //
via=(bit)(busy&0x80);
}while(via);
}
void Write_Byte_1602(u8 Byte,bit dat)
{
lcd1602_check_busy(); //Wait if busy
rs_1602=dat; //Data command selection bit
rw_1602=0;
en_1602=1;
DB1602=Byte;
_nop_();
en_1602=0;
}
void lcd1602_Init()
{
Write_Byte_1602(0x38,0); //Set 16×2 display, 5×7 dot matrix, 8-bit data interface
Write_Byte_1602(0x08,0);
Write_Byte_1602(0x01,0); //Clear screen
Write_Byte_1602(0x06,0); //Display cursor movement settings
Write_Byte_1602(0x0c,0); //Display on and cursor setting
}
void Write_char1_1602(bit x,u8 y,u8 dat1)
{
if(x==0)
{
Write_Byte_1602(0x80+y,0);
}
else
{
Write_Byte_1602(0xc0+y,0);
}
//dat1+=0x30;
Write_Byte_1602(dat1,1);
}
void Write_string_1602(bit x,u8 y,u8 *str)
{
if(x==0)
{
Write_Byte_1602(0x80+y,0);
}
else
{
Write_Byte_1602(0xc0+y,0);
}
while(*str)
{
Write_Byte_1602(*str,1);
str++;
}
}
This code looks a little more complicated than the original program, but it is still some basic content, so everyone should understand it first. If you don’t understand something, you can look up the information first. This program uses something I haven’t mentioned before - pointers, which I will list separately and explain later.
Previous article:Design case of intelligent dormitory air conditioning management system based on HMI-Board
Next article:Analysis of the Limiting Circuit in Digital Power Amplifier
Recommended ReadingLatest update time:2024-11-16 09:58
- Popular Resources
- Popular amplifiers
- Single-chip microcomputer C language programming and simulation
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- stm32+lcd1602 example
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
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