Many newcomers or engineers encounter some very complicated problems when programming a single chip. In fact, many of the problems we have have small tricks to simplify it. The following is the chip driver of LCD1602 to talk about the skills in C51 microcontroller programming is very easy to use. Since the chip driver for LCD1602 is HD44780, if your LCD1602 driver chip is not HD44780, the following contents may not be applicable.
LCD1602 is an LCD display that can display two lines of characters. Each line can write 40 characters, but each line can only display the first 16 characters. The 24 characters after each line cannot be displayed immediately. It is not easy to understand. Let's take a look at the diagram below:
In addition, LCD1602 can only display characters, numbers and some simple symbols, it is impossible to display Chinese characters, remember.
LCD1602 pin:
Then let's talk about the pins. When learning a chip or module, the first thing to know is the pin:
Since we are only learning how to program now, the connection of the circuit is not mentioned. Let's talk about the pins related to programming:
1. RS pin: data / command selection (H / L)
When you want to send an instruction to the LCD, give this pin a low level;
Give this pin a high level when you want to interact with the LCD.
2. R/W pin: read/write select (H/L)
When you want to write data to the LCD, give this pin a low level;
When you want to read the data in the LCD, give this pin a high level.
3. E pin: enable end (here to take care of the person who loves the horns: Why is E called "enable"? Also "enable" means, how have I never heard of it?)
Answer 1: E pin English full name: Enable pin, En is a prefix in English, translated as "make...", and the following can be translated as "capable", so together they are called "enable" Pin out.
A2: What does it mean? Let's not say the terminology. You can understand that the enable is a switch. When this pin is high/low, the device is usable when it is at the opposite level. This device is useless, and it doesn't work anyway. Of course, is the low-level device effective, or is the high-level device effective? This depends on the specific device data sheet or some of the pins will be directly marked, such as E is active high, E (-) is active low.
4. D0 ~ D7 pin: This is nothing to say, is the transmission of data or command pins.
5. Other power supply pins, backlight power supply, do not say anything, the table has been very clear, and we are only learning programming, circuit connection does not speak.
After the pin is finished, then we can talk about the programming part of LCD1602:
I think the two parts, timing and instructions that need to be remembered for LCD1602 (not to be completely remembered, write a function library after learning, and call it directly after development)
Let me talk about the timing and initialization process:
LCD1602 read timing:
The source code of the read function is not written, after all, this is almost useless.
Can be seen in the figure:
The RS pin is determined according to what you read. The data is read high and the read command is low.
The RW pin is naturally high, because we have to read it;
Then there is the E pin later. When we read the command or data, we must first enable the device, so the E pin should be set high.
Finally, D0 to D7 are the data read. We will find an array of variables to save.
Although the reading sequence is finished, in the actual development we almost do not need to read, I think someone will say at this time: Is not to read the busy flag, then do not have to read? This is true, but the speed of the LCD1602 is nanosecond, and the 51 MCU is of the millisecond level, so there is basically no need to read the busy flag, as long as the micro delay is enough.
[Note] Two methods are used in the function, and 4 and 8 ports are used.
Let's talk about the most important write operation timing. It can be seen from the figure:
The RS pin is determined according to what you read. The data is read high and the read command is low.
The RW pin is naturally low, because we have to write this time;
Then there is the E pin later. When we read the command or data, we must first enable the device, so the E pin should be set high.
Finally, D0 to D7 are the data or commands written.
LCD1602 process
Here is the code:
The initialization of LCD1602, that is, the initialization process of HD44780 chip, the version of this initialization process is too much, most of the initialization process can be successfully initialized, but I am writing an article here, naturally can not talk about a messy initialization process, So I checked the English original data sheet of the HD44780 chip, the following picture:
If you want to understand, then you can look at it from the top to the next step, and then understand why the initialization should be written as above.
[Note] Many initialized versions can be successfully initialized. The one I said is only the most formal, personal preference, as long as it can be initialized successfully.
Finally, write the header file of LCD1602, and then the function library of LCD1602 is ready. Of course, we didn't write the read function. If you want to write it, you can add it yourself. With this function library, it is convenient to call directly when using LCD1602 in the future.
Residual Current Circuit Breaker
RCCB named Residual Current Circuit Breaker. When there is human electricity shock or if the leakage current of the line exceeds the prescribed value, Residual current circuit breaker/RCCB(without over-current protection) will cut off the power rapidly to protect human safety and prevent the accident due to the current leakage. The rccb switch which made from Korlen electric can be used as infrequent changeover of the line in normal situation.
Korlen electric ---- the rccb switch manufacturer,produces types of Residual Current Circuit Breaker. It is applicable to industrial site, commercial site, tall building and civil house.
Residual Current Circuit Breaker,Ac Residual Current Circuit Breaker,Miniature Residual Current Circuit Breaker,Residual Current Electrical Circuit Breaker
Wenzhou Korlen Electric Appliances Co., Ltd. , https://www.zjthermalrelay.com