Difference between revisions of "HD44780"
(→I2C) |
(→I2C) |
||
Line 191: | Line 191: | ||
The I2C connection type supports either the 8 Bit PCF8574x, as it is found on the Pollin AVR Net-IO Add-On board, or the 16 Bit MCP23017 I2C Port Expander. | The I2C connection type supports either the 8 Bit PCF8574x, as it is found on the Pollin AVR Net-IO Add-On board, or the 16 Bit MCP23017 I2C Port Expander. | ||
− | LCDs up to 80 characters and only one HD44780 controller may be connected to a | + | LCDs up to 80 characters and only one HD44780 controller may be connected to a PCF8574x including the backlight control pin. LCDs with more than 80 characters require a second enable pin. The address of the port expander and the pinning for the LCD has to be specified for your hardware using the macros shown below. The macro HD44780_PCF8574x_MAPPING defines the pinning for displays with only one enable signal and backlight control, the macro HD44780_PCF8574x_MULTI_MAPPING for displays with two enable signals. Note that backlight control is not supported when using the HD44780_PCF8574x_MULTI_MAPPING macro. The pinning shown in the examples below matches the pinning found on the Pollin AVR Net-IO Add-On board. Remember that you have to replace the inverting backlight control circuitry with a direct connection to connect displays with two enable signals to this board. |
− | The macros HD44780_MCP23017_MAPPING and HD44780_MCP23017_MULTI_MAPPING are used to map the LCD pins to one port of the MCP23017. Note that you have to specify either port A or B as shown below, mapping using mixed pins of both ports is not supported by the driver. The additional macro HD44780_MCP23017_MULTI_MAPPING_BL may be used to specify a backlight control signal on another MCP23017 port when the first port is occupied by a display with two enable signals. | + | The macros HD44780_MCP23017_MAPPING and HD44780_MCP23017_MULTI_MAPPING are used to map the LCD pins to one port of the MCP23017. Note that you have to specify either port A or B as shown below, mapping using mixed pins of both ports is not supported by the driver. The additional macro HD44780_MCP23017_MULTI_MAPPING_BL may be used to specify a backlight control signal on another MCP23017 port when the first port is occupied by a display with two enable signals. The driver exclusively controls the pin specified, the other 7 port pins may be used for different purposes. |
<code> | <code> |
Revision as of 21:12, 9 December 2016
HD44780 | |
---|---|
Status | Stable
|
menuconfig | I/O->LCD Displays->HD44780 module driver (Character-LCD) |
Pinning | yes |
Ecmd | yes |
Control6 | yes |
Depends on | ECMD |
Requires | - |
Code | https://github.com/ethersex/ethersex/tree/master/hardware/lcd |
THIS WIKI PAGE IS CURRENTLY WORK IN PROGRESS
The HD44780 module provides support for common alphanumeric character LCDs using Hitachis HD44780 and compatible controllers.
Contents
Supported LC-Displays
The vast majority of all alphanumeric LC-Displays use Hitachis HD44780 dot matrix liquid crystal display (LCD) controller. The e6 HD44780 module supports displays of many different sizes utilizing the original HD44780 and compatible controllers.
Alphanumeric LCDs are mainly distinguished by their size, the start-address of the per line Display Data-RAM (DDRAM) and the controller type. The original HD44780 controllers can drive up to 80 characters - most displays with more characters use two independent controllers.
The following table lists the LC-displays supported by the e6 HD44780 module by size and per line DDRAM start-address:
Menuconfig | Size | DDRAM Startaddress | Note: | ||||
---|---|---|---|---|---|---|---|
LCD size/type | Characters | Lines | Line 1 | Line 2 | Line 3 | Line 4 | |
8_Characters_1_Line | 8 | 1 | 0x00 | n/a | n/a | n/a | |
16_Characters_1_Line | 16 | 1 | 0x00 | n/a | n/a | n/a | |
16_Characters_1_Line_Mux16 | 16 | 1 | 0x00 | n/a | n/a | n/a | organized as 8 chars, 2 lines |
20_Characters_1_Line | 20 | 1 | 0x00 | n/a | n/a | n/a | |
40_Characters_1_Line | 40 | 1 | 0x00 | n/a | n/a | n/a | |
8_Characters_2_Lines | 8 | 2 | 0x00 | 0x40 | n/a | n/a | |
12_Characters_2_Lines | 12 | 2 | 0x00 | 0x40 | n/a | n/a | |
16_Characters_2_Lines | 16 | 2 | 0x00 | 0x40 | n/a | n/a | |
20_Characters_2_Lines | 20 | 2 | 0x00 | 0x40 | n/a | n/a | |
24_Characters_2_Lines | 24 | 2 | 0x00 | 0x40 | n/a | n/a | |
40_Characters_2_Lines | 40 | 2 | 0x00 | 0x40 | n/a | n/a | |
16_Characters_4_Lines | 16 | 4 | 0x00 | 0x40 | 0x10 | 0x50 | |
20_Characters_4_Lines | 20 | 4 | 0x00 | 0x40 | 0x14 | 0x54 | Note DDRAM addresses |
20_Characters_4_Lines_KS0073 | 20 | 4 | 0x00 | 0x20 | 0x40 | 0x60 | Note DDRAM addresses |
27_Characters_4_Lines_2_EN | 27 | 4 | 0x00 | 0x40 | 0x00 | 0x40 | Two Enable-Pins/Controllers |
40_Characters_4_Lines_2_EN | 40 | 4 | 0x00 | 0x40 | 0x00 | 0x40 | Two Enable-Pins/Controllers |
Note: The HD44780 module drivers supports alphanumeric character LCDs only. Ethersex also has limited support for some graphical displays. Have a look at the LC-Display configuration.
Configuration
... │ │ Network ---> │ │ I/O ---> ... │ │ ADC / DAC ---> │ │ LCD Displays ---> ... │ │ [*] HD44780 module driver (Character-LCD) ---> │ │ [-] HR20-style LCD Display ... │ │ (16_Characters_2_Lines) LCD size/type │ │ (HD44780_Compat) LCD controller type │ │ (None) LCD charset conversion │ │ (I2C) Connection type │ │ (PCF8574) I2C Port Expander │ │ [*] Readback support │ │ [*] Backlight support │ │ [*] Backlight on at power-on │ │ [*] Invert Backlight switch
Configuration options:
- LCD size/type
- Select one of the defined display sizes and address configurations shown in the table #Supported LC-Displays above.
- Although it is technically possible to connect more than one display, the HD44780 module supports only one LC-Display at a time.
- LCD controller type
- Select LCD controller circuit:
-
- HD44780_Compat - most controllers are compatible to Hitachis HD44780
- KS0066U - Samsungs KS0066U requires a different init routine
- Almost all controllers for alphanumeric character LCDs are more or less HD44780-compatible at least at the feature- and function-level required by e6.
- If in doubt, choose HD44780_Compat.
- LCD charset conversion
- Select charset conversion used while writing to the lcd:
-
- None - use no charset conversion at all (safes program mem)
- HD44780_Compat - map characters from ISO8859-1 to the original HD44780 charset
- Almost all controllers use their own non-ISO-compatible charset, varying between manufacturers, rom versions, etc. that provides characters from western languages as well as japanese, chinese and graphical glyphs.
- Charset conversion might become useful if you have to display messages and texts from external resources that uses standard encodings for their charset like ISO8859-1.
- Note: Charset conversion uses a lookup table and requires about 272 byte program memory (flash rom).
- Connection type
- Select the connection type for the LCD:
-
- Direct - direct connection using avr io-pins
- I2C - uses sub-selection of I2C port expander
- SER_LCD(74hct164) - serial connection using HCT164 shift register
- 2WIRE(74hct4094) - serial connection using HCT4094 shift register
- See section #Pinning below for further explanations.
- I2C Port Expander
- Select I2C Port Expander to use:
-
- PCF8574 - use PCF8574x as I2C port expander
- MCP23017 - use MCP23017 as I2C port expander
- Note: automatically enables I2C_MASTER_SUPPORT and I2C_PCF8574X_SUPPORT resp. I2C_MCP23017_SUPPORT when selected.
- Note: Selection is only valid when I2C was selected under Connection type.
- See section #Pinning below for further explanations.
- Readback support
- Enable support for bi-directional lcd bus to read LCDs busy flag. Supported by direct and I2C connection only.
- You definitly should use a readback capable hardware and enable this feature, saves lots of delays.
- Backlight support
- Backlight support for LCDs based on the HD44780 controller.
- Enable backlight on/off control via API and ECMD.
- Backlight on at power-on
- Switch on backlight at power-on/reset.
- Invert Backlight switch
- Invert backlight logic for low active backlight circuits e.g. found on Pollin AVR NET-IO Add-on.
Pinning
HD44780-based alphanumeric LCDs are connected via 8 databus-lines (D0..D7) and 3 control-lines (RS, EN, R/W). Displays with more than 80 characters usually utilize a second controller and require two EN-signals EN1 and EN2. Another signal BL is needed if backlight control ist required. To save some i/o-pins the HD44780 controller also supports a 4 Bit mode, using only D4..D7. The HD44780 module supports this 4 Bit mode only. Note that in general the signals D0..D3 should not be left open, use a pull-down or tie them to ground.
Most displays use 14, 16 or 18-pin connectors with common pinouts but there are sometimes subtle differences. Beside the control- and data-signals all displays require a supply voltage Vdd, usually +5 V, for the logic circuits and another voltage Vo for the display itself. The later is usually derived using a trimmer which allows for contrast adjustment. Some displays require a negative voltage for the display.
Please refer to the datasheet of your display! Wrong connections may lead to a permanent damage.
The HD44780 module supports four different types of connection: Direct, I2C, Serial and 2-Wire.
Direct
The LCD signals RS, RW, EN (resp. EN1 and EN2), D4..D7 and BL are directly connected to AVR port pins. The driver makes no assumptions about the pin mapping, arbitrary pins from different ports may be used to drive the LCD signals. This connection type is Readback-capable.
The following example maps the LCD pins to AVR port pins found on the 25 pin Sub-D connector of the Pollin AVR Net-IO board:
dnl Direct connection example dnl map LCD pins to Pollin AVR Net-IO dnl 25 pin extension port ifdef(`conf_HD44780', ` pin(HD44780_RS, PC4) pin(HD44780_RW, PC3) pin(HD44780_EN1, PC2) dnl pin(HD44780_EN2, PC5) pin(HD44780_D4, PA0) pin(HD44780_D5, PA1) pin(HD44780_D6, PA2) pin(HD44780_D7, PA3) ') ifdef(`conf_HD44780_BACKLIGHT', ` pin(HD44780_BL, PC6, OUTPUT) ')
I2C
The I2C connection type supports either the 8 Bit PCF8574x, as it is found on the Pollin AVR Net-IO Add-On board, or the 16 Bit MCP23017 I2C Port Expander.
LCDs up to 80 characters and only one HD44780 controller may be connected to a PCF8574x including the backlight control pin. LCDs with more than 80 characters require a second enable pin. The address of the port expander and the pinning for the LCD has to be specified for your hardware using the macros shown below. The macro HD44780_PCF8574x_MAPPING defines the pinning for displays with only one enable signal and backlight control, the macro HD44780_PCF8574x_MULTI_MAPPING for displays with two enable signals. Note that backlight control is not supported when using the HD44780_PCF8574x_MULTI_MAPPING macro. The pinning shown in the examples below matches the pinning found on the Pollin AVR Net-IO Add-On board. Remember that you have to replace the inverting backlight control circuitry with a direct connection to connect displays with two enable signals to this board.
The macros HD44780_MCP23017_MAPPING and HD44780_MCP23017_MULTI_MAPPING are used to map the LCD pins to one port of the MCP23017. Note that you have to specify either port A or B as shown below, mapping using mixed pins of both ports is not supported by the driver. The additional macro HD44780_MCP23017_MULTI_MAPPING_BL may be used to specify a backlight control signal on another MCP23017 port when the first port is occupied by a display with two enable signals. The driver exclusively controls the pin specified, the other 7 port pins may be used for different purposes.
ifelse(value_HD44780_CONNECTION,`HD44780_I2CSUPPORT',`dnl ifelse(value_HD44780_I2C_PORTEXP,`HD44780_I2C_PCF8574', `ifdef(`conf_HD44780_MULTIEN', `dnl dnl HD44780_PCF8574x_MULTI_MAPPING(ADR, RS, RW, EN1, EN2, DB4, DB5, DB6, DB7) HD44780_PCF8574x_MULTI_MAPPING(0x20, 4, 5, 6, 7, 0, 1, 2, 3)', `dnl dnl HD44780_PCF8574x_MAPPING(ADR, RS, RW, EN, DB4, DB5, DB6, DB7, BL) HD44780_PCF8574x_MAPPING(0x20, 4, 5, 6, 0, 1, 2, 3, 7)')', value_HD44780_I2C_PORTEXP,`HD44780_I2C_MCP23017', `ifdef(`conf_HD44780_MULTIEN', `dnl dnl HD44780_MCP23017_MULTI_MAPPING(ADR, PORT, RS, RW, EN1, EN2, DB4, DB5, DB6, DB7) HD44780_MCP23017_MULTI_MAPPING(0x24, B, 4, 5, 6, 7, 0, 1, 2, 3) HD44780_MCP23017_MULTI_MAPPING_BL(0x24, A, 7)', `dnl dnl HD44780_MCP23017_MAPPING(ADR, RS, RW, EN, DB4, DB5, DB6, DB7, BL) HD44780_MCP23017_MAPPING(0x24, B, 4, 5, 6, 0, 1, 2, 3, 7)')' )dnl ')dnl
Serial (using 74HCT164)
The LCD is connected using a 74HC(T)164 shift register. Refer to Ulrich Radig's avr-webserver for an example of this connection type. The connection is uni-directional, so no Readback. Don't use if speed is important, especially not for larger displays.
dnl serial connection requires three AVR port pins pin(HD44780_SER_D, PD4) pin(HD44780_SER_CLK, PD3) pin(HD44780_SER_EN1, PD2)