The EE 109 LCD Shield

Similar documents
The EE 109 LCD Shield

6.1. EE 109 Unit 6. LCD Interfacing

Embedded Systems and Software. LCD Displays

FPGA Interfacing of HD44780 Based LCD Using Delayed Finite State Machine (FSM)

Embedded Systems and Software

ECE 4510/5530 Microcontroller Applications Week 9

AN1745. Interfacing the HC705C8A to an LCD Module By Mark Glenewinkel Consumer Systems Group Austin, Texas. Introduction

LCD Display. Other I/O. LCD display Flash ROM SPI EPROM Keyboard (PS/2) UART connectors DAC ADC. 2-line, 16 character LCD display

12.1. Unit 12. Exceptions & Interrupts

EMBEDDED HARDWARE DESIGN. Tutorial Interfacing LCD with Microcontroller /I

Dragon12 LCD Displays Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) Dragon12 LCD Display. The Dragon12 board has a 16 character x 2 line display

Dragon12 LCD Displays Huang Sections 7.8 Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) ATD_10B8C Block User Guide. Dragon12 LCD Display

LCD AND KEYBOARD INTERFACING

EE 109 Unit 4. Microcontrollers (Arduino) Overview

19.1. Unit 19. Serial Communications

Serial Communications

Lab 5: LCD and A/D: Digital Voltmeter

Dragon12 LCD Displays Hantronix_CLD.PDF data sheet (Dragon12 CD-ROM) Dragon12 LCD Display. The Dragon12 board has a 16 character x 2 line display

IAS0430 MICROPROCESSOR SYSTEMS

Programming Microcontroller Assembly and C

EE251: Thursday September 20

LCDs. Embedded Systems Interfacing. 20 September 2011

Lecture (09) PIC16F84A LCD interface LCD. Dr. Ahmed M. ElShafee

Lab 5: LCD and A/D: Digital Voltmeter

// sets the position of cursor in row and column

CLCD1 Serial 1 wire RS232 LCD development board

LABORATORY MANUAL Interfacing LCD 16x2, Keypad 4x4 and 7Segment Display to PIC18F4580

Getting Started Guide

ADC to I 2 C. Data Sheet. 10 Channel Analog to Digital Converter. with output via I 2 C

SC1602LC 16x2 Large Characters RS232 LCD Module. User s Manual. Large Viewing Area 99mm x 24mm. Large Character Size. 4.84mm x 9.66mm.

commodore semiconductor group NMOS 950 Rittenhouse Rd., Norristown, PA Tel.: 215/ TWX: 510/ (MEMORY, I/O, TIMER ARRAY)

1/Build a Mintronics: MintDuino

Alphanumeric LCD display module 24 characters by 2 line. General description

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

Power Driver 16 v2. Version 2.0 July 5, 2017

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

Laboratory 3 Working with the LCD shield and the interrupt system

PSIM Tutorial. How to Use SPI in F2833x Target. February Powersim Inc.

Embedded Systems and Software

DOT MATRIX CHARACTER LCD MODULE USER S MANUAL

AVR Intermediate Development Board. Product Manual. Contents. 1) Overview 2) Features 3) Using the board 4) Troubleshooting and getting help

INTERFACING 16 2 LCD WITH 8051

Embedded Systems and Software

DIGITAL HUMIDITY SENSOR HYT-131

LCD. Configuration and Programming

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

Lab Overview. Lab Details. ECEN 4613/5613 Embedded System Design Week #7 Spring 2005 Lab #4 2/23/2005

Cab Bus Communications Protocol

Laboratory 1 Introduction to the Arduino boards

AN703. Micro64/128. Accessing the 36k of SRAM 12/3/04

Fall 2017 Project Assignment Speed Trap

LDR_Light_Switch2 -- Overview

Device: FDRV-04S. This document version: v1. Matches module version: v2 [2 Oct 2015] Document revision date: 9 November 2015

AVR Board Setup General Purpose Digital Output

Adafruit VL53L0X Time of Flight Micro-LIDAR Distance Sensor Breakout

LCD03 - I2C/Serial LCD Technical Documentation

AVR ISA & AVR Programming (I)

SX1509 I/O Expander Breakout Hookup Guide

ZL10AVR. Versatile Evaluation Board for AVR Microcontrollers

Microcontroller and Embedded Systems:

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

Lab-3: LCDs Serial Communication Analog Inputs Temperature Measurement System

RS 232 PINOUTS. 1. We use RJ12 for all of our RS232 interfaces (Link-2-Modbus & Link-2-PC- Serial/RS232). The diagram below shows our pin out.

Unit 13 Timers and Counters

Exam 1. Date: February 23, 2016

Spring 2017 Project Assignment Alarm Clock with Indoor/Outdoor Thermometer

Introduction. Unit 4. Numbers in Other Bases in C/C++ BIT FIDDLING. Microcontrollers (Arduino) Overview Digital I/O

Page 1 of 7. Samtron/Samsung 20S204DA2

Adapted from a lab originally written by Simon Hastings and Bill Ashmanskas

Chapter 4. Address. data. Input / Output Programming. Simplified Z80 System Architecture. Memory. program. data. Z80 I/O Programming

ET-BASE AVR ATmega64/128

LABORATORY 1 INTRODUCTION TO 8085 MICROPROCESSOR DEVELOPMENT SYSTEM BOARD

Mayhew Labs. Extended ADC Shield User Manual

The Atmel ATmega168A Microcontroller

CPEG300 Embedded System Design. Lecture Interface with Peripheral Devices

LT900SERIES. 1xN Multi-Channel Switch Operation Manual

The Atmel ATmega328P Microcontroller

EM270 COMMUNICATION PROTOCOL. Version 1 Revision 0

Parallel Display Specifications Revision 1.0

EM210 COMMUNICATION PROTOCOL. Version 3 Revision 1

How2Use DT-AVR ATMEGA168 BMS. By: IE Team. Picture 1 The layout of DT-AVR ATMEGA168 BMS

LCD03 - I2C/Serial LCD Technical Documentation

DEV-1 HamStack Development Board

MICROPROCESSORS A (17.383) Fall Lecture Outline

TN-192. Bar Graph shows analog trends on a dot-matrix character LCD module. Introduction. LCD Module Basics. Custom Characters

Electronics Single Board Computers

Functional block diagram AD53x1 (Analog Devices)

University of Florida EEL 4744 Spring 2011 Dr. Eric M. Schwartz Department of Electrical & Computer Engineering 31 March Apr-11 1:29 PM

EE389 EDL Report, EE Deptt., IIT Bombay, Nov RF linked Handheld Terminal

Application Note. Interfacing the CS5521/22/23/24/28 to the 68HC05. Figure 1. 3-Wire and 4-Wire Interfaces

Logosol Joystick Node LS-731

LDR_Light_Switch1 -- Overview

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

Introduction To Arduino

C:\Users\jacob\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

Laboratory 10. Programming a PIC Microcontroller - Part II

SPECIFICATIONS FOR LCD MODULE

Goal: We want to build an autonomous vehicle (robot)

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

AVR 40 Pin Rapid Robot controller board

Transcription:

EE 109 Unit 9 LCD 1

LCD BOARD 2

3 The EE 109 LCD Shield The LCD shield is a 16 character by 2 row LCD that mounts on top of the Arduino Uno. The shield also contains five buttons that can be used as input sources. 5 Button Inputs

4 How Do We Use It? By sending it data (i.e. ASCII characters one at a time) that it will display for us By sending it special commands to do things like: Move the cursor to a specific location Clear the screen contents Upload new fonts/special characters

5 How Do We Communicate? The LCD uses a "parallel" interface (4-bits sent per transfer) to communicate with the µc (Note: µc => microcontroller) Data is transferred 4 bits at a time and uses 2 other signals (Register Select and Enable) to control where the 4-bits go and when the LCD should capture them Uno D7 D6 D5 D4 Data lines EE 109 is fun! Walk your bike! D8 D9 Register Select Enable LCD

6 Commands and Data LCD contains two 8-bit registers which it uses to control its actions: Command and Data A Register Select (RS) signal determines which register is the destination of the data we send it (RS acts like an address selector) RS = 0, info goes into the command register RS = 1, info goes into the data register To perform operations like clear display, move cursor, turn display on or off, write the command code to the command register. To display characters on the screen, write the ASCII code for the character to the data register. Command Clear LCD Curser Home (Upper-Left) Display On Display Off Move cursor to top row, column i Move cursor to bottom row, column i Code 0x01 0x02 0x0f 0x08 0x80+i 0xc0+i

7 How Do We Communicate? To transfer data we send it in two groups of 4 First the upper 4-bits followed by the lower 4-bits RS=0 sets the destination as the command reg. RS=1 sets the destination as the data reg. Uno D7 D6 D5 D4 D8 D9 Data lines Register Select Enable 2 nd Transfer 1 0 0 1 0 1 st Transfer 0 0 1 1 0 Address (Reg. Select) 0 1 7 6 5 4 3 2 1 0 0011 1001 Command Reg. Data Reg. LCD Display HW

8 How Do We Communicate? To transfer data we send it in two groups of 4 First the upper 4-bits followed by the lower 4-bits RS=0 sets the destination as the command reg. RS=1 sets the destination as the data reg. Uno D7 D6 D5 D4 D8 D9 Data lines Register Select Enable 2 nd Transfer 0 0 0 1 1 1 st Transfer 0 1 1 0 1 Address (Reg. Select) 0 1 7 6 5 4 3 2 1 0 0011 0110 LCD 1001 Command Reg. 0001 Data Reg. Display HW

9 Another View Data from the Uno is transferred by placing four bits on the data lines (PD[7:4]). The Register Select (RS) line determines whether the data goes to the LCD s "Command Register" or "Data Register" RS=0 => Command Register RS=1 => Data Register The Enable (E) line acts as a "clock" signal telling the LCD to capture the data and examine the RS bit on the 0-1-0 transition Pulse must be held at 1 for at least 230ns according to LCD datasheet (PB0) RS "0000 0101" sent to the command register in the LCD The first 4-bits of a transfer to the data register in the LCD (PD[7:4]) Data 0000 0101 0110 (PB1) Enable 230 ns 230 ns 230 ns

10 Another View Data from the Uno is transferred by placing four bits on the data lines (PD[7:4]). Whether sending info to the "command" or "data" register, the LCD still wants a full byte (8-bits) of data so we must do 2 transfers We always send the upper 4-bits of the desired data first Then we transfer the lower 4-bits (PB0) RS "0000 0101" sent to the command register in the LCD The first 4-bits of a transfer to the data register in the LCD (PD[7:4]) Data 0000 0101 0110 (PB1) Enable 230 ns 230 ns 230 ns

11 Who's Job Is It? So who is producing the values on the RS and Data lines and the 0-1-0 transition on the E line? You!! With your digital I/O (setting and clearing PORT bits) // Turn on bit 0 of PORTD PORTD = 0x01 // Delay 1 us > 230ns needed _delay_us(1); // Turn off bit 0 of PORTD PORTD &= ~(0x01) This code would produce some voltage pattern like this on PD0 (PD0) Note: The LCD connection doesn't use PD0, you'll need to modify this appropriately to generate the E signal

12 Other LCD Interface Other LCD devices may use Only one signal (a.k.a. serial link) to communicate between the µc and LCD This makes wiring easier but requires more complex software control to "serialize" the 8- or 16-bit numbers used inside the µc 8-data wires plus some other control signals so they can transfer an entire byte This makes writing the software somewhat easier

LCD LAB PREPARATION 13

14 Step 1 Mount the LCD shield on the Uno without destroying the pins Download the test.hex file and Makefile from the web site, and modify the Makefile to suite your computer. Run make test to download test program to the Uno+LCD. Should see a couple of lines of text on the screen.

15 Step 2 Develop a set of functions that will abstract the process of displaying text on the LCD A set of functions to perform specific tasks for a certain module is often known as an API (application programming interface) Once the API is written it gives other application coders a nice simple interface to do high-level tasks Download the skeleton file and examine the functions outlines on the next slides

16 LCD API Development Overview Write the routines to control the LCD in layers Top level routines that yours or others code can use: write a string to LCD, initialize LCD, etc. Mid level routines: write a byte to the command register, write a byte to the data register Low level routines: controls data lines and E to transfer a nibble to a register Goal: Hide the ugly details about how the interface actually works from the user who only wants to put a string on the display.

17 High Level API Routines init_lcd() Does all the steps to initialize the LCD See the lab writeup and follow it exactly as written Uses: writenibble(), writecommand(), delays moveto(unsigned char row, unsigned char col) Moves the LCD cursor to row (1 or 2) and col (1-16) Translates from row/column notation to the format the LCD uses for positioning the cursor (see lab writeup) Uses: writecommand() stringout(char *s) Writes a string of character starting at the current cursor position Uses: writedata()

18 Mid-Level Functions writecommand(unsigned char x) Send the 8-bit byte x to the LCD as a command Set RS to 0, send data in two nibbles, delay Uses: writenibble() writedata(unsigned char x) Send the 8-bit byte x to the LCD as data Set RS to 1, send data in two nibbles, delay Uses: writenibble() Could do as one function writebyte(unsigned char x, unsigned char rs)

19 Low Level Functions writenibble(unsigned char x) Assumes RS is already set appropriately Send four bits from x to the LCD Takes 4-bits of x and copies them to PD[7:4] (where we've connected the data lines of the LCD) Produces a 0-1-0 transition on the Enable signal Must be consistent with mid-level routines as to which 4 bits to send, MSB or LSB Uses: logical operations (AND/OR) on the PORT bits

20 Step 3 Complete the LCD Lab after first understanding how to use the buttons present on the LCD shield Information about how to use the buttons is presented in the next slides

21 LCD Shield Buttons The LCD shield has 5 buttons However, they do not produce 5 individual signals like you are used to from previous labs They are configured in such a way such that they sum together to produce a single analog voltage which the shield connects to the A0 input of the Arduino If the voltage is in certain range we can infer that a particular button is being pressed 5 Button Inputs => 1 analog voltage A0 Uno

22 LCD Shield Buttons You can use the Arduino's A-to-D converter to sense when a button is pressed Each button produces a certain voltage when pressed and the default value of 5V when no button is pressed The table to the right shows the nominal voltages and 10-bit ADC result Note these are nominal and could be different so it would be best to just split the range evenly (e.g. to know the 'Up' button is pressed check if the 10-bit ADC results is between 104 and 308) Button Volts (V) Avg. 10-bit Value Right 0 V 0 Up 1.0 V 208 Down 2.0 V 408 Left 3.1 V 624 Select 4.0 V 816 None 5V 1023

23 Ensuring the Enable pulse is long enough THE DEVIL IN THE DETAILS

24 Making Things Work Together Does your code do the right thing? Lab 6 required the program to generate an Enable (E) pulse. Example: The writenibble() routine controls the PB1 bit that is connected to the LCD Enable line. PORTB = (1 << PB1); // Set E to 1 PORTB &= ~(1 << PB1); // Clear E to 0 Creates a 0 1 0 pulse to clock data/commands into LCD. But is it a pulse that will work with the LCD? Rumors circulated that the E pulse had to be made longer by putting a delay in the code that generated it. Don t Guess. Time to read the manual, at least a little bit.

Making Things Work Together 25 Timing Characteristics Check the LCD controller datasheet HD44780U RS VIH1 VIL1 VIH1 VIL1 t AS t AH R/W VIL1 VIL1 PW EH t AH t Ef E VIH1 VIL1 VIH1 VIL1 VIL1 t Er t DSW t H DB0 to DB7 VIH1 VIL1 Valid data VIH1 VIL1 t cyce Figure 27 Write Operation

26 Making Things Work Together Check the generated code Can check the code generated by the compiler to see what is happening. For the creation of the E pulse the compiler generated this code: SBI PORTB, 1 ; Set Bit Immediate, PORTB, bit 1 CBI PORTB, 1 ; Clear Bit Immediate, PORTB, bit 1 According to the manual, the SBI and CBI instructions each take 2 clock cycles 16MHz 62.5nsec/cycle, so pulse will be high for 125nsec

Making Things Work Together 27 Check with the oscilloscope

28 Making Things Work Together Extend the pulse At 125nsec, the E pulse it not long enough although it might work on some boards. Can use _delay_us() or _delay_ms() functions but these are longer than needed since the minimum delay is 1 us (=1000 ns) and we only need 230 ns Trick for extending the pulse by a little bit: PORTB = (1 << PB1); // Set E to 1 PORTB = (1 << PB1); PORTB &= ~(1 << PB1); // Clear E to 0 // Add another 125nsec to the pulse

Making Things Work Together 29 Better looking pulse

30 Making Things Work Together Extend the pulse (geek way) Use the asm compiler directive to embed low level assembly code within the C code. The AVR assembly instruction NOP does nothing, and takes 1 cycle to do it. PORTB = (1 << PB1); // Set E to 1 asm( nop ::); asm( nop ::); PORTB &= ~(1 << PB1); // Clear E to 0 // NOP delays another 62.5ns

31 Making Things Work Together Don t guess that things will work When working with a device, make sure you know what types of signals it needs to see Voltage Current Polarity (does 1 mean enable/true or does 0) Duration (how long the signal needs to be valid) Sequence (which transitions comes first, etc.) Have the manufacturer s datasheet for the device available Most of it can be ignored, but some parts are critical Learn how to read it When in doubt follow the acronym used industry-wide: RTFM (read the *!@^-ing manual)