Difference between revisions of "RPi Tutorial EGHS:Alpha-Numeric Display"
m (→Circuit 1 - Alpha-Numeric LCD Module via 6 GPIO outputs) |
m (→TI LaunchPad) |
||
Line 130: | Line 130: | ||
Sample test code for LCD Test Module (tested on TI MSP430G2553 device). | Sample test code for LCD Test Module (tested on TI MSP430G2553 device). | ||
− | + | ====Circuit 1 - 6 GPIO - Pin Mapping ==== | |
+ | {|style="border-collapse: separate; border-spacing: 0; border-width: 1px; border-style: solid; border-color: #000; padding: 0" | ||
+ | |- | ||
+ | !style="border-style: solid; border-width: 0 1px 1px 0"| LCD Module | ||
+ | !style="border-style: solid; border-width: 0 1px 1px 0"| Launch Pad | ||
+ | !style="border-style: solid; border-width: 0 1px 1px 0"| Note | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 1 - Power Supply Vss(GND) | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| TP3 - GND USB Supply | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| ''Connection pin manually added to LaunchPad'' | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 2 - Power Supply Vdd(+V) | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| TP4 - +5V USB Supply | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| ''Connection pin manually added to LaunchPad'' | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 3 - Vo (Contrast) | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| Connected directly to pin 1 on LCD Module | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| ''Alternatively a variable resistor across 5-0V may be required'' | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 4 - RS (Reg Select) | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| P1.7 - GPIO Digital Output Pin | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 5 - R/W (Read/Write) | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| Connected directly to pin 1 on LCD Module | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| ''Always Write, so GND pin is fine'' | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 6 - E (Enable Signal) | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| P1.6 - GPIO Digital Output Pin | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 7 - Data DB0 | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| No Connection | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 8 - Data DB1 | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| No Connection | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 9 - Data DB2 | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| No Connection | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 10 - Data DB3 | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| No Connection | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 11 - Data DB4 | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| P1.0 - GPIO Digital Output Pin | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 12 - Data DB5 | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| P1.1 - GPIO Digital Output Pin | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 13 - Data DB6 | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| P1.2 - GPIO Digital Output Pin | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 14 - Data DB7 | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| P1.3 - GPIO Digital Output Pin | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 15 - A (Backlight +) | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| No Connection | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| ''Not Available (although can connect to 5V if it is)'' | ||
+ | |- | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| 16 - K (Backlight -) | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| No Connection | ||
+ | |style="border-style: solid; border-width: 0 1px 0 0"| ''Not Available (although can connect to GND if it is)'' | ||
+ | |} | ||
Code: | Code: | ||
− | |||
===RPi=== | ===RPi=== |
Revision as of 02:42, 27 February 2012
Back to the Hub, or the Tutorials page.
GPIO Hardware & Software Tutorials:
- GPIO Protection Circuits
- Basic Circuits: LED output - DC motor - Switch Input - Analogue Sensor
- Intermediate Circuits: Shift Registers - Analogue to Digital - Driving Circuit - Alpha-Numeric Display
- Advanced Circuits: Control Hardware Over The Internet
This page is part of a work in progress.
Warnings
While most of these circuits may interface directly to the RPi, the use of a buffered interface (such as the one supplied by the Gertboard) is recommended which will help protect against damage. Alternatively, experiment with one of the Alternative Test Platforms.
Extreme caution should be exercised when interfacing hardware at a low level, you may damage your RPi, your equipment and potentially yourself and others. Doing so is at your own risk!
Aims
This tutorial is closely based on the excellent work done by Gaurav Chaudhary[1], on his blog 16x2 Char LCD with TI MSP430 Launch Pad.
The purpose of this tutorial will be to adapt the setup for use with the RPi, and to further develop the code for easier interfacing.
In addition to this, the tutorial will adapt the follow-up post 16x2 Serial LCD (Two Wire) with PIC12F675 for use with TI MSP430 Launch Pad and ultimately the RPi.
This would provide a useful standard for connecting an LCD display to the RPi using up just 2 GPIO pins, allowing easy debugging even for a setup which otherwise does not use a display.
Clearly there is no sense in replicating everything here, so the tutorial will focus mainly on the second part and also (when possible) how to translate this onto the RPi.
It is recommended, that you take the time to read through the above blog posts and, if interested, I recommend looking through the rest of Gaurav Chaudhary's[2] posts too.
Note: Until RPi devices are available, I can not confirm this will work on a real RPi. For now, I shall be using the TI LaunchPad (see Alternative Test Platforms for details) to test the hardware on (as it is cheap and the logic levels similar).
The Hardware
Theory
The theory of operation is covered very well on Gaurav Chaudhary's[3] blog post for 16x2 Char LCD with TI MSP430 Launch Pad.
The circuits will be focused on the setup that will be required for running these Alpha Numeric Modules with the RPi (should be identical to TI Launchpad setup).
For this setup, the Powertip PC 1602-H module [4] will be used (simply because I already had one), however most Alpha Numeric LCD displays use the same Hitachi HD44780 based driver (or similar) will be suitable (just take note of the pinouts if they are different).
Both circuits, will drive the LCD using a 5V supply while applying 3.3V logic to the data and control pins, since while lower voltage displays are available, the 5V ones are the cheapest and we have more current available through the RPi via the 5V line anyway.
Circuit 1 - Alpha-Numeric LCD Module via 6 GPIO outputs
Note: In order to control the LCD Display using 4-bit data, the top 4 data lines are used D4-D7 of the LCD.
PC1602-H Pin Connections
Pin | Function | Connection |
---|---|---|
1 | Power Supply Vss(GND) | Power Supply Vss(GND) |
2 | Power Supply Vdd(+V) | Power Supply Vdd +5V |
3 | Vo (Contrast) | GND or variable resistor across 5-0V |
4 | RS (Reg Select) | GPIO Digital Output Pin |
5 | R/W (Read/Write) | Power Supply Vss(GND) - Always Write |
6 | E (Enable Signal) | GPIO Digital Output Pin |
7 | Data DB0 | Not Used |
8 | Data DB1 | Not Used |
9 | Data DB2 | Not Used |
10 | Data DB3 | Not Used |
11 | Data DB4 | GPIO Digital Output Pin |
12 | Data DB5 | GPIO Digital Output Pin |
13 | Data DB6 | GPIO Digital Output Pin |
14 | Data DB7 | GPIO Digital Output Pin |
15 | A (Backlight +) | Not Available (although can connect to 5V if it is) |
16 | K (Backlight -) | Not Available (although can connect to GND if it is) |
With the exception of possibly a variable resistor across +5V and GND, connected to pin 3 (Vo - Contrast) if required, no additional components are needed(the GPIO connections can be connected directly to the processor (i.e the RPi) GPIO pins.
Circuit 2 - Alpha-Numeric via 2 GPIO outputs
The Software
While the RPi is not available, I can only confirm the TI LaunchPad code works for me.
TI LaunchPad
Sample test code for LCD Test Module (tested on TI MSP430G2553 device).
Circuit 1 - 6 GPIO - Pin Mapping
LCD Module | Launch Pad | Note |
---|---|---|
1 - Power Supply Vss(GND) | TP3 - GND USB Supply | Connection pin manually added to LaunchPad |
2 - Power Supply Vdd(+V) | TP4 - +5V USB Supply | Connection pin manually added to LaunchPad |
3 - Vo (Contrast) | Connected directly to pin 1 on LCD Module | Alternatively a variable resistor across 5-0V may be required |
4 - RS (Reg Select) | P1.7 - GPIO Digital Output Pin | |
5 - R/W (Read/Write) | Connected directly to pin 1 on LCD Module | Always Write, so GND pin is fine |
6 - E (Enable Signal) | P1.6 - GPIO Digital Output Pin | |
7 - Data DB0 | No Connection | |
8 - Data DB1 | No Connection | |
9 - Data DB2 | No Connection | |
10 - Data DB3 | No Connection | |
11 - Data DB4 | P1.0 - GPIO Digital Output Pin | |
12 - Data DB5 | P1.1 - GPIO Digital Output Pin | |
13 - Data DB6 | P1.2 - GPIO Digital Output Pin | |
14 - Data DB7 | P1.3 - GPIO Digital Output Pin | |
15 - A (Backlight +) | No Connection | Not Available (although can connect to 5V if it is) |
16 - K (Backlight -) | No Connection | Not Available (although can connect to GND if it is) |
Code:
RPi
References
|