Thanh navigation

Thứ Ba, 9 tháng 8, 2022

16×2 lcd in 4-bit and 8-bit mode (LCD: Part 3)

 After making many microcontroller projects with character lcd’s(16×1,16×2) and interfacing them with variety of microcontrollers (arduino, microchip pin microcontroller,8051 series,stm32 etc). I still get emails from students about what is the difference between character lcd interfacing in 4-bit and 8-bit mode. So i decided why not to write a post on difference between lcd 4-bit and 8-bit mode interfacing. 

In this short tutorial i will try to explain the basic difference between the two modes and the advantages/disadvantages in using the either of the two. This post will help the newbies putting their step in embedded field to easily understand the two modes. Character lcd’s come in many sizes 8×1 , 8×2 , 10×2 , 16×1 , 16×2 , 16×4 , 20×2 , 20×4 ,24×2 , 30×2 , 32×2 , 40×2 etc. Each character lcd has 8-bit data port to connect with external controllers.  All the character lcds can be used in 8-bit as well as 4-bit mode.

I assume that you have an introduction to character lcds and know about their internal structure, pin out, registers, commands etc. If you don’t I recommend to first take the introduction tutorial and then resume with this post.

lcd 4bit and 8bit mode – Major difference

The major difference in 4 bit and 8 bit mode lies in data pins used and lcd initializing commands.

Since character lcd’s has 8 data pins so they accept only 8-bit data. Character datatype is 8-bit wide. So character values can easily be send to lcd. This mode is know as 8-bit mode in which we send an 8-bit value such as character or ASCII value to lcd. 

In 4 bit mode only four data pins are used. Character 8-bit ASCII value is divided in to two 4-bit nibbles. High nibble is sent first following by the lower nibble. So in theory two strokes are needed to send a character(8-bit) to lcd when we are using lcd in 4-bit mode. 

In contrast in 8-bit communication mode, 8-bit ASCII value of character is send in a single stroke to lcd.

Thus the 4-bit mode generates latency. Although 4-bit mode generates latency it on the other hand saves 4 gpio(general purpose input out pins) of the external controller sending data to lcd. Which can be utilized else where.   

The gif animation below explains the difference between 4-bit and 8-bit mode very beautifully.

16x2 lcd in 4 bit and 8 bit mode with microcontroller

16×2 lcd in 4 bit and 8 bit mode with microcontroller

Lcd in 4-bit mode

Commands used to initialize the 4-bit lcd mode 

  • To initialize character lcd in 4 bit mode we send value hex 0x20 to command register of lcd. 0x20 tells the lcd controller that we want to communicate in 4-bit mode. Lcd is 1 line (has 1 row) and we want character shape displayed in 5×7 matrix.
  • If our character lcd has 2 lines (rows) we will send 0x28 instead of 0x20. It tells the lcd controller that we want 4 bit communication and character size is between 5×7 dot matrix.
  • 4-bit mode make use of only just four data pins D4-D5-D6-D7.
  • In 4-bit mode character is displayed on lcd in two pulse signals. First the higher four nibbles of a character are sent to the lcd with an enable stroke. Than the lower four nibbles are send with enable stroke.
  • Since two pulse (enable) signals are required to display a single character so 4-bit mode latency time is high.

Some Projects made using character lcd in 4-bit mode.

Lcd in 8-bit mode

Commands used to initialize the 8-bit lcd mode are

  • To initialize character lcd in 8-bit mode we send vale hex 0x30 to command register of lcd. 0x30 tells lcd that we want to communicate in 8-bit mode. Lcd is 1 line (has 1 row) and we want character shape displayed in 5×7 matrix. 
  • If our character lcd has 2 lines (rows) we will send 0x38 instead of 0x20. It tells the lcd controller that we want 4 bit communication and character size is between 5×7 dot matrix.
  • In 8-bit mode only one pulse signal is required to display a character on lcd.
  • Thus it is faster than 4-bit mode.

Some Projects made using character lcd in 8-bit mode.

  https://www.engineersgarage.com/lcd-in-4-bit-mode-and-8-bit-mode/

Không có nhận xét nào:

Đăng nhận xét