MEMS cvičenie 3: Rozdiel medzi revíziami
Zo stránky SensorWiki
Bez shrnutí editace  | 
				|||
| Riadok 55: | Riadok 55: | ||
* Nuts & Volts: [http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv31.pdf Demystifying Character Based LCDs]  | * Nuts & Volts: [http://www.parallax.com/dl/docs/cols/nv/vol1/col/nv31.pdf Demystifying Character Based LCDs]  | ||
* Stamp Works - pp. 73 and more [http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf]  | * Stamp Works - pp. 73 and more [http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf]  | ||
=== Arduino ===  | === Arduino ===  | ||
| Riadok 141: | Riadok 143: | ||
[[Obrázok:LCD_App_Mod_Schematic.png|center|450px]]  | [[Obrázok:LCD_App_Mod_Schematic.png|center|450px]]  | ||
== 4-miestny 7-segmentový displej  LED  displej ==  | |||
* 4-miestny 7-segmentový displej   | |||
** Product page http://www.gme.sk/hd-m324rd-p512-924  | |||
** Datasheet http://www.gme.sk/img/cache/doc/512/924/hd-m324rd-datasheet-1.pdf  | |||
** Animácia k 7seg displeju: http://www.uize.com/examples/seven-segment-display.html  | |||
Verzia z 18:52, 5. marec 2016
Pripojenie LED a LCD displeja a lokálne zobrazenie meranej veličiny
- LCD zobrazovač. Klávesnica. 
Obšírnejšie informácie o displejoch (prednáška z predmetu MMP) 
Programovateľný LCD displej
LCD Modul

Vlastnosti:
- 2x8 LCD Displej bez podsvetlenia
 - 4 Tlačítka
 - Trimer na zmenu kontrastu
 
Technické parametre:
- Napájanie: 5 V @ 15 mA
 - Pripojenie: 4-Bit parallel interface (Hitachi HD44780 compatible)
 - Rozmery: 60 x 50 x 20 mm
 - Pracovná teplota: 0 až +70 °C
 


Úlohy
Najprv sa snažte pochopiť, ako je vytvorený vzorový program, ako sa konfiguruje pripojenie LCD k portom, skontrolujte konfiguráciu. Potom s pomocou manuálu k displeju zobrazte na displeji nejaký text a zrealizujte nasledovné funkcie:
- posun kurzora doprava / dolava
 - posun obsahu displeja doprava / dolava
 - napíšte funkciu void lcdGotoXY(riadok, stlpec)
 - clear displeja (a obnovenie povodneho obsahu displeja)
 - zadefinujte si vlastné znaky a zobrazte ich spolu s iným textom. Povinne aspoň jeden znak s diakritikou a znak stupeň, zobrazte teplotu.
 
Literatúra
- Katalógové listy
- Radič Hitachi HD44780
 - Displej 2x16 DEM 16216 SYH-LY
 - Displej 2x16 DEM 20231 SYH-PY
 - 2x16 Parallel LCD datasheet
 - Podrobné manuály sú aj u výrobcu Hantronix.
 
 
- Peter Ouwehand: How to control a HD44780-based Character-LCD
 - Ian Harries: HD44780-Based LCD Modules'
 - Tomáš Dresler: Inteligentní displeje a jejich připojení k PC. [hw.cz]
 - Nuts & Volts: Demystifying Character Based LCDs
 - Stamp Works - pp. 73 and more [1]
 
Arduino
Nasledovný príklad je pre Arduino.
/*
  LiquidCrystal Library - Hello World
 
 Demonstrates the use a 8x2 LCD display.  
 
   The circuit:
 * LCD RS pin to digital pin 3
 * LCD R/W pin to digital pin 2
 * LCD Enable pin to digital pin 1
 * LCD D4 pin to digital pin 4
 * LCD D5 pin to digital pin 5
 * LCD D6 pin to digital pin 6
 * LCD D7 pin to digital pin 7                    
 */
#include <LiquidCrystal.h>           // include the library 
// initialize the library with the numbers of the interface pins
//  LiquidCrystal(RS, RW, EN, D4, D5, D6, D7) 
LiquidCrystal lcd( 3,  2,  1,  4,  5,  6,  7);
void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(8, 2);
  // Print a message to the LCD.
  lcd.print("Ahoj!");
}
void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
  // print the status of buttons:
  lcd.setCursor(6, 0);
  lcd.print(ReadButtons(),HEX);
  
}
/* ------------------------------------------------------- */
/*  Read and debounce the LCD AppMod buttons               */
/*                                                         */
/*  Returns 0 if nothing  is pressed                       */
/*  Returns 1 if button A is pressed                       */
/*  Returns 2 if button B is pressed                       */
/*  Returns 4 if button C is pressed                       */
/*  Returns 8 if button D is pressed                       */
/*  Returns combination if more is pressed (e.g. 6 for B+C)*/
/*                                                         */
/* ------------------------------------------------------- */
unsigned char ReadButtons()
{
  DDRD  = 0b00001110;                // make LCD bus inputs
  unsigned char state = 0xFF;           // assume nothing pressed
  
  for(int scan = 1; scan<=10; scan++)
  {
   state = state & ((PIND&0xF0)>>4); // make sure button held
   delay(5);                     // debounce 10 x 5 ms
  }
  DDRD  = 0b11111110;				 // return bus to outputs
  
  return(state);
}
Misc:
Prečo je takto napísaná a ako vlastne funguje lepšie zistíte, keď si preštudujete schému zapojenia:

4-miestny 7-segmentový displej LED displej
- 4-miestny 7-segmentový displej
- Product page http://www.gme.sk/hd-m324rd-p512-924
 - Datasheet http://www.gme.sk/img/cache/doc/512/924/hd-m324rd-datasheet-1.pdf
 - Animácia k 7seg displeju: http://www.uize.com/examples/seven-segment-display.html