Operácie

LCD displej s radičom HD44780: Rozdiel medzi revíziami

Z SensorWiki

(Opis displeja)
(Opis displeja)
Riadok 4: Riadok 4:
  
 
[[Súbor:HD44780pinout.png|200|left]]
 
[[Súbor:HD44780pinout.png|200|left]]
#Ground
+
 
#VCC +3.3 to +5V (typical)
+
 
#Contrast adjustment (VO) This is an analog input, typically connected to a potentiometer. The user must be able to control this voltage independent of all other adjustments, in order to optimise visibility of the display that varies i.a. with temperature, and, in some cases height above the sea level. With a wrong adjustment the display will seem to malfunction.
+
 
#Register Select (RS).  RS=0: Command, RS=1: Data
+
{| class="wikitable" style="text-align:center;"
#Read/Write (R/W).  R/W=0: Write, R/W=1: Read (In most applications reading from the HD44780 makes no sense. In that case this pin can be permanently connected to ground and no io pins need to be allocated to steer it.)
+
|-
#Clock (Enable).  Falling edge triggered
+
! 1
#Bit 0  (Not used in 4-bit operation)
+
! style="font-weight:bold; background-color:#000000; color:#ffffff;" | GND
#Bit 1  (Not used in 4-bit operation)
+
! style="text-align:left;" | Ground, zem<br />
#Bit 2  (Not used in 4-bit operation)
+
|-
#Bit 3  (Not used in 4-bit operation)
+
| 2
#Bit 4
+
| style="font-weight:bold; background-color:#fe0000;" | Vcc
#Bit 5
+
| style="text-align:left;" | Napájanie, typ. +5V
#Bit 6
+
|-
#Bit 7
+
| 3
#Backlight Anode (+) (If applicable)
+
| style="font-weight:bold; background-color:#fd6864;" | Vo
#Backlight Cathode (-) (If applicable)
+
| style="text-align:left;" | Nastavenie kontrastu, 0 < Vo < Vcc
 +
|-
 +
| 4
 +
| style="font-weight:bold; background-color:#fcff2f;" | RS
 +
| style="text-align:left;" | Register Select, výber registra - Command RS=0 alebo Data RS=1
 +
|-
 +
| 5
 +
| style="font-weight:bold; background-color:#fcff2f;" | R/W
 +
| style="text-align:left;" | Read/Write 0: Write, 1: Read (zriedkavo používaný)
 +
|-
 +
| 6
 +
| style="font-weight:bold; background-color:#fcff2f;" | E
 +
| style="text-align:left;" | Enable - aktivačný signál, aktívna je dobežná hrana
 +
|-
 +
| 7
 +
| style="font-weight:bold; background-color:#efefef;" | D0
 +
| style="text-align:left;" | Data bit D0
 +
|-
 +
| 8
 +
| style="font-weight:bold; background-color:#efefef;" | D1
 +
| style="text-align:left;" | Data bit D1
 +
|-
 +
| 9
 +
| style="font-weight:bold; background-color:#efefef;" | D2
 +
| style="text-align:left;" | Data bit D2
 +
|-
 +
| 10
 +
| style="font-weight:bold; background-color:#efefef;" | D3
 +
| style="text-align:left;" | Data bit D3
 +
|-
 +
| 11
 +
| style="font-weight:bold; background-color:#32cb00;" | D4
 +
| style="text-align:left;" | Data bit D4 (používa sa v 4-bitovom zapojení)
 +
|-
 +
| 12
 +
| style="font-weight:bold; background-color:#32cb00;" | D5
 +
| style="text-align:left;" | Data bit D5 (používa sa v 4-bitovom zapojení)
 +
|-
 +
| 13
 +
| style="font-weight:bold; background-color:#32cb00;" | D6
 +
| style="text-align:left;" | Data bit D6 (používa sa v 4-bitovom zapojení)
 +
|-
 +
| 14
 +
| style="font-weight:bold; background-color:#32cb00;" | D7
 +
| style="text-align:left;" | Data bit D7 (poižíva sa v 4-bitovom zapojení)
 +
|-
 +
| 15
 +
| style="font-weight:bold; background-color:#fe0000;" | A+
 +
| style="text-align:left;" | Podsvietenie - anóda
 +
|-
 +
| 16
 +
| style="font-weight:bold; background-color:#343434; color:#ffffff;" | K-<br />
 +
| style="text-align:left;" | Podsvietenie - katóda<br />
 +
|}
 +
 
 +
 
 +
{| class="wikitable"
 +
|- style="font-weight:bold; text-align:center; font-family:Arial, Helvetica, sans-serif !important;;"
 +
! colspan="3" style="background-color:#96fffb;" | Port B
 +
! style="font-weight:normal; text-align:left;" |
 +
! colspan="3" style="background-color:#fcff2f;" | Port C
 +
! style="font-weight:normal; text-align:left;" |
 +
! colspan="3" style="background-color:#D58CE0;" | Port D
 +
|- style="font-family:Arial, Helvetica, sans-serif !important;;"
 +
| style="background-color:#CFF;" | D8
 +
| style="font-weight:bold; background-color:#96fffb;" | PB0
 +
| style="font-weight:bold;" | ICP1 / CLK0
 +
|
 +
| style="background-color:#fafad3;" | D14
 +
| style="vertical-align:middle; background-color:#fffe65;" | PC0
 +
| style="font-weight:bold;" | A0
 +
|
 +
| style="background-color:#ffccff;" | D0
 +
| style="vertical-align:middle; font-weight:bold; background-color:#d58ce0;" | PD0
 +
| style="font-weight:bold;" | RxD
 +
|- style="font-family:Arial, Helvetica, sans-serif !important;;"
 +
| style="background-color:#CFF;" | D9
 +
| style="font-weight:bold; background-color:#96fffb;" | PB1
 +
| style="font-style:italic;" | lcd D0
 +
|
 +
| style="background-color:#fafad3;" | D15
 +
| style="vertical-align:middle; background-color:#fffe65;" | PC1
 +
| style="font-weight:bold;" | A1
 +
|
 +
| style="background-color:#ffccff;" | D1
 +
| style="vertical-align:middle; font-weight:bold; background-color:#d58ce0;" | PD1
 +
| style="font-weight:bold;" | TxD
 +
|- style="font-family:Arial, Helvetica, sans-serif !important;;"
 +
| style="background-color:#CFF;" | D10
 +
| style="font-weight:bold; background-color:#96fffb;" | PB2
 +
| style="font-style:italic;" | lcd D1
 +
|
 +
| style="background-color:#fafad3;" | D16
 +
| style="vertical-align:middle; background-color:#fffe65;" | PC2
 +
| style="font-style:italic;" | sw03
 +
|
 +
| style="background-color:#ffccff;" | D2
 +
| style="vertical-align:middle; font-weight:bold; background-color:#d58ce0;" | PD2
 +
| style="font-style:italic;" | lcd RS
 +
|- style="font-family:Arial, Helvetica, sans-serif !important;;"
 +
| style="background-color:#CFF;" | D11
 +
| style="font-weight:bold; background-color:#96fffb;" | PB3
 +
| style="font-style:italic;" | lcd D2
 +
|
 +
| style="background-color:#fafad3;" | D17
 +
| style="vertical-align:middle; background-color:#fffe65;" | PC3
 +
| style="font-style:italic;" | led02
 +
|
 +
| style="background-color:#ffccff;" | D3
 +
| style="vertical-align:middle; font-weight:bold; background-color:#d58ce0;" | PD3
 +
| style="vertical-align:middle;" | lcd R/W (?)
 +
|- style="font-family:Arial, Helvetica, sans-serif !important;;"
 +
| style="background-color:#CFF;" | D12
 +
| style="font-weight:bold; background-color:#96fffb;" | PB4
 +
| style="font-style:italic;" | lcd D3
 +
|
 +
| style="background-color:#fafad3;" | D18
 +
| style="vertical-align:middle; background-color:#fffe65;" | PC4
 +
| style="font-weight:bold;" | SDA
 +
|
 +
| style="background-color:#ffccff;" | D4
 +
| style="vertical-align:middle; font-weight:bold; background-color:#d58ce0;" | PD4
 +
| style="font-style:italic;" | lcd E
 +
|- style="font-family:Arial, Helvetica, sans-serif !important;;"
 +
| style="background-color:#CFF;" | D13
 +
| style="font-weight:bold; background-color:#96fffb;" | PB5
 +
| style="font-weight:bold;" | LED
 +
|
 +
| style="background-color:#fafad3;" | D19
 +
| style="vertical-align:middle; background-color:#fffe65;" | PC5
 +
| style="font-weight:bold;" | SCL
 +
|
 +
| style="background-color:#ffccff;" | D5
 +
| style="vertical-align:middle; font-weight:bold; background-color:#d58ce0;" | PD5
 +
| style="font-weight:bold;" | T1 / PWM
 +
|-
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
|
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;; background-color:#ffccff;" | D6
 +
| style="vertical-align:middle; font-weight:bold; font-family:Arial, Helvetica, sans-serif !important;; background-color:#d58ce0;" | PD6
 +
| style="font-style:italic; font-family:Arial, Helvetica, sans-serif !important;;" | sw01
 +
|-
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
|
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;;" |
 +
| style="font-family:Arial, Helvetica, sans-serif !important;; background-color:#ffccff;" | D7
 +
| style="vertical-align:middle; font-weight:bold; font-family:Arial, Helvetica, sans-serif !important;; background-color:#d58ce0;" | PD7
 +
| style="font-style:italic; font-family:Arial, Helvetica, sans-serif !important;;" | sw02
 +
|}
  
 
== Pripojenie ==
 
== Pripojenie ==

Verzia zo dňa a času 23:33, 29. január 2021

Opis displeja

200


1 GND Ground, zem
2 Vcc Napájanie, typ. +5V
3 Vo Nastavenie kontrastu, 0 < Vo < Vcc
4 RS Register Select, výber registra - Command RS=0 alebo Data RS=1
5 R/W Read/Write 0: Write, 1: Read (zriedkavo používaný)
6 E Enable - aktivačný signál, aktívna je dobežná hrana
7 D0 Data bit D0
8 D1 Data bit D1
9 D2 Data bit D2
10 D3 Data bit D3
11 D4 Data bit D4 (používa sa v 4-bitovom zapojení)
12 D5 Data bit D5 (používa sa v 4-bitovom zapojení)
13 D6 Data bit D6 (používa sa v 4-bitovom zapojení)
14 D7 Data bit D7 (poižíva sa v 4-bitovom zapojení)
15 A+ Podsvietenie - anóda
16 K-
Podsvietenie - katóda


Port B Port C Port D
D8 PB0 ICP1 / CLK0 D14 PC0 A0 D0 PD0 RxD
D9 PB1 lcd D0 D15 PC1 A1 D1 PD1 TxD
D10 PB2 lcd D1 D16 PC2 sw03 D2 PD2 lcd RS
D11 PB3 lcd D2 D17 PC3 led02 D3 PD3 lcd R/W (?)
D12 PB4 lcd D3 D18 PC4 SDA D4 PD4 lcd E
D13 PB5 LED D19 PC5 SCL D5 PD5 T1 / PWM
D6 PD6 sw01
D7 PD7 sw02

Pripojenie

Schéma zapojenia

MIPS lcdDemoSchema01.png
Schéma pripojenia LCD displeja k procesoru.

Pokúste sa najprv pripojiť displej len podľa schémy zapojenia. Ak sa vám to nepodarí, alebo si chcete byť naistom, skontrolujte si zapojenie aj podľa zapojovacej schémy.

MIPS lcdDemoSchema02.png
Schéma pripojenia vodoočov LCD displeja k procesoru.


To, či máte displej pripojený správne si môžete vyskúšať týmto demo programom, ktorý preložíte a nahráte z prostredia Arduino.

#include <LiquidCrystal.h>
// connection      RS R/W E D4 D5 D6 D7
LiquidCrystal lcd ( 2,  3,4, 9,10,11,12);

// define some user characters
byte smiley[8] = {
  0b00000,
  0b00000,
  0b01010,
  0b00000,
  0b00000,
  0b10001,
  0b01110,
  0b00000 };

byte step1[8] = {
  0b01100, 0b01100, 0b00000, 0b01110,
  0b11100, 0b01100, 0b11010, 0b10011};

byte step2[8] = {
  0b01100, 0b01100, 0b00000, 0b01100,
  0b01100, 0b01100, 0b1100,  0b01110};

void setup() {
  lcd.begin(16, 2);    // init LCD + set number of columns and rows

  lcd.createChar(1, smiley);    // create a new characters
  lcd.createChar(3, step1);
  lcd.createChar(4, step2);

  lcd.setCursor(0, 0);          // set the cursor to the top left

  lcd.write(byte(1));           // smiley
  lcd.print(" UAMT FEI STU ");  // normal text
  lcd.write((byte)1);           // smiley 
}

void loop() {
    lcd.setCursor(2, 1);         // set curspr to line 2 col 3
    lcd.print("time: ");         // print the number of seconds since reset:
    lcd.print(millis() / 1000);
    lcd.setCursor(12, 1);
    lcd.write(3);                // draw the little man
    delay(delayTime);
    lcd.setCursor(12, 1);
    lcd.write(4);
    delay(delayTime);
}
ToDo

Na displeji by sa vám mal zobraziť text, počítadlo a jednoduchá animácia ako na obrázku

MIPS lcdDemoFoto.jpg
Schéma pripojenia vodoočov LCD displeja k procesoru.


Q: Čo s nepoužitými vstupmi?

A1: pripojiť na definovanú úroveň, najlepšie cez pull-up/pull-down rezistor.

A2: Keďže podľa datasheetu[REF 1] má riadiaci obvod Hitachi HD44780 zapojené pull-upy interne, tak nie sú potrebné.

A3: Keďže však nevieme, aký riadiaci čip je v skutočnosti použitý, pre istotu ich môžeme zapojiť.


Vysvetlivky, prečo sú nezapojené vstupy nebezpečné:

Nezapojené (plávajúce) vstupy sú oveľa citlivejšie na ESD (elektrostatický výboj) a taktiež zvyšujú zbytočne spotrebu obvodu. Odporúča sa pripojenie cez tzv. pull-up odpor priamo na zem, prípadne aj bez odporu. Druhá možnosť, pripojenie na kladné napájacie napätie je tiež možná, ale v tomto prípade sa vynechanie pull-up rezistora neodporúča.

Toto je jeden z príkladov mnohých takýchto odporúčaní[REF 2] priamo od firmy NxP:

5.3 Line Termination and Pullup/Pulldown Resistors
  • Line termination and pullup/pulldown resistors may be required to guarantee voltage levels at high impedance or unused pins (do not tie directly to VDD/VSS)
  • Floating input pins may store intermediate voltage levels that would cause current drain on internal logic gates
  • Floating pins are also prone to pick up noise and suffer electrostatic discharge stress (ESD)


Literatúra

  1. Hitachi HD44780U Dot Matrix Liquid Crystal Display Controller/Driver. ADE-207-272(Z), Japan, 1999.
  2. Murray Stewart: AN3393: MC9RS08KA Application Hints. NxP/Freescale Semiconductor Application Note, 2007.


Odkazy