RASPI LCD
Neues Display neues Glück
Es werden vermehrt Geräte mit diesen Display weggeworfen.
da ist es mal wieder an der Zeit das Display zu testen.
Anschluß: GPIO sind auch Wiring PI Pins
Pin 1 GnD Vss --------- GND RPI Pin 6
Pin 2 VSS Pwr --------- +5V RPI Pin 2
Pin 3 LCD Contrast ---- GND RPI Pin 6 (ca. 2K Ohm dazwischen)
Pin 4 RS -------------- GPIO 1 Pin 12
Pin 5 R/W ------------- GND RPI Pin 6
Pin 6 Enable ---------- GPIO 0 RPI Pin 11
Pin 11 Data 4 --------- GPIO 3 RPI Pin 15
Pin 12 Data 5 --------- GPIO 4 RPI Pin 16
Pin 13 Data 6 --------- GPIO 5 RPI Pin 18
Pin 14 Data 7 --------- GPIO 6 RPI Pin 22
Zunächst kann man das Programm nehmen und den Text einfach auf das Display bringen. Die Routine bricht einfach nach Ende der Länge des Display um. Oder man steuert die einezelnen Zeilen direkt an.
LCDINIT: Zeilen, Spalten, Mode (4bit 8 bit), D0 - D7, bei 4 Bit Mode wie unten aufgeführt.
Das Programm lcd.c
#include <wiringPi.h>
#include <lcd.h>
// gute Beschreibung findet sich hier:
// http://www.circuitbasics.com/raspberry-pi-lcd-set-up-and-programming-in-c-with-wiringpi
// USE WIRINGPI PIN NUMBERS
// compile: gcc -o lcd lcd.c -lwiringPi -lwiringPiDev
//
#define LCD_RS 1 //Register select pin
#define LCD_E 0 //Enable Pin
#define LCD_D4 3 //Data pin 4
#define LCD_D5 4 //Data pin 5
#define LCD_D6 5 //Data pin 6
#define LCD_D7 6 //Data pin 7
int main()
{
int lcd;
wiringPiSetup();
// Zeilen Spalten Mode(4bit)
lcd = lcdInit (4, 20, 4, LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7, 0, 0, 0, 0);
lcdPosition(lcd, 0, 0);
lcdPuts(lcd, "123456789001234567890");
lcdPosition(lcd, 0, 1);
lcdPuts(lcd, "1Hello, world!");
lcdPosition(lcd, 0, 2);
lcdPuts(lcd, "123456789012345678901234567890");
}
// http://www.circuitbasics.com/raspberry-pi-lcd-set-up-and-programming-in-c-with-wiringpi
// USE WIRINGPI PIN NUMBERS
// compile: gcc -o lcd lcd.c -lwiringPi -lwiringPiDev
//
#define LCD_RS 1 //Register select pin
#define LCD_E 0 //Enable Pin
#define LCD_D4 3 //Data pin 4
#define LCD_D5 4 //Data pin 5
#define LCD_D6 5 //Data pin 6
#define LCD_D7 6 //Data pin 7
int main()
{
int lcd;
wiringPiSetup();
// Zeilen Spalten Mode(4bit)
lcd = lcdInit (4, 20, 4, LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7, 0, 0, 0, 0);
lcdPosition(lcd, 0, 0);
lcdPuts(lcd, "123456789001234567890");
lcdPosition(lcd, 0, 1);
lcdPuts(lcd, "1Hello, world!");
lcdPosition(lcd, 0, 2);
lcdPuts(lcd, "123456789012345678901234567890");
}
Älterer Beitrag:
Das LCD Display funktioniert nun, wie ich es will. Ich möchte nur über die Shell eine Ausgabe haben und sonst nichts.
Verdrahtungs Chaos.... Es gibt GPIO, Wiring PI und RPI- Pinouts. Das C-Programm benutzt die BCM GPIO Notation. Eine gute Tabelle hierzu ist hier: http://wiringpi.com/pins/ zu finden.
RPI-PIN BCM Port
EN: 11 17
RS: 12 18
D0: 15 22
D1: 16 23
D2: 18 24
D3: 22 25
Nach langer Suche bin ich auf dieser Seite auf ein C-Programm gestoßen. Dort ist auch der komplette Quellcode. Ich habe mir das Programm umgebaut und nur noch folgende Zeilen gelassen:
******************** Programm lcd ********************
/*
* main.c
* Written, if that's the word, by Phil Bambridge
* with much help from John Honniball.
*/
#include <stdio.h>
#include "lcd.h"
struct lcdmodule module;
void updateDisplay (struct lcdmodule module, unsigned int displayOption);
int main(int argc, char *argv[]) {
struct lcdmodule module2;
// Here we create and initialise two LCD modules.
// The arguments are, in order, EN, RS, D4, D5, D6, D7.
module = lcdInit(17, 18, 22, 23, 24, 25);
module2 = lcdInit(21, 18, 22, 23, 24, 25);
int displayOption = 0;
//Zeile 1
gotoXy(module, 0,0);
prints(module, argv[1]);
// Zeile 2
gotoXy(module, 0,1);
prints(module, argv[2]);
return 0;
} // main
******************** Programm lcd ends ********************
Der Aufruf ist ganz einfach:
sudo lcd "Zeile1" "Zeile 2 :-)"
Das eigentliche Programm ist auch nett.
In der while Schleife habe ich das IP unknown auskommentiert und das Interface wlan0 bei else eingebaut.
******************** programm lcdinfo.c ********************
while(1) {
gotoXy(module, 0,0);
prints(module, " ");
// TODO: This should be capable of blanking out a line wider than 16 chars.
gotoXy(module, 0,0);
// Print eth0's IP address in dotted-quad format
if (get_addr("eth0",theip) == 0) {
prints(module, theip);
} else {
if (get_addr("wlan0",theip) == 0) {
prints(module, theip); // prints(module, "IP unknown!");
}
}
******************** programm lcdinfo.c ends ********************
das Programm startet auf Wunsch automatisch und gibt die Daten bei Systemstart aus:
cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
sudo /usr/bin/lcdinfo &
exit 0
Version 2.0
Bei Pollin Electronic gibt es ein wirklich preiswertes LCD Display, welches auch mit dem HD47780 Befehlssatz angesteuert werden kann:
Das Display nennt sich LCD-Modul C0802-04 und kostet bei Pollin schlappe 0,95 Eur
Problem: Am Anschluß ist schlecht löten. Das Isolationsmaterial löst sich sofort auf.
Zum Glück hat das Teil noch Lötösen. Mit ruhiger Hand und Geduld kann man da was anlöten.
Zunächst die Flexleitung ablöten.
Zunächst die Flexleitung ablöten.
So ist das Display ohne Anschluß.
Hier ist schon das Display am Raspberry angeschlossen.
sudo lcd "Hallo" "Raspi"
eben nur 8 Zeichen und 2 Zeilen. Für einige Dinge ausreichend. Vor allen Dingen ist das Display extrem flach, nur 3mm. Daher optimal um es in ein Raspberry Gehäuse zu montieren.
Mit der ganz oben beschriebenen Software kann man das Display ansteuern. Der Sourcecode ist hier zu finden: http://pmb.neongrit.net/blog/?p=64
Wer, wie ich, in c nicht programmieren, kann das einfache lcd Progarmm hier laden (irgendwie habe ich mir das Programm zusammenkompiliert)
Programm lcd für Raspberry PI
Hier noch die Anschlussbelegung:
Display PIN 1 ------ Raspberry GPIO Pin 6 (GND)
Display PIN 2 ------ Raspberry GPIO Pin 2 (+5V)
Display PIN 3 ------ Raspberry GPIO Pin 6 (GND)
Display PIN 4 ------ Raspberry GPIO Pin 12 (RS)
Display PIN 5 ------ Raspberry GPIO Pin 6 (GND)
Display PIN 6 ------ Raspberry GPIO Pin 11 (E)
Display PIN 7 ------ Raspberry GPIO Pin 15 (D4)
Display PIN 8 ------ Raspberry GPIO Pin 16 (D5)
Display PIN 9 ------ Raspberry GPIO Pin 18 (D6)
Display PIN 10 ------ Raspberry GPIO Pin 22 (D7)
Hier ein kleines Script für einen Lauftext auf das Display:
#!/bin/bash
# Lauftext für LCD Display. Aufruf ./lauftext.sh "Text"
inhalt=" "$1" "
width=8;
pause=0.2
length=${#inhalt};
IFS="";
# We will kann auch eine endlos Schleife haben
# while [[ 1 ]]; do
pos=0;
while [[ $pos -lt $length ]]
do
text=$(echo -n ${inhalt:$pos:$width})
sudo lcd $text
pos=$((pos + 1));
sleep $pause;
done;
# done;
IP Adresse automatisch bei Systemstart auf das kleine Display ausgeben:
cat /etc/rc.local
#
# Print the IP address on LCD
text=$(echo $_IP)
/home/pi/lauftext.sh $text &
LCD Display Samsung 0282A Controller M50530
Probieren wir mal das Display am Raspberry zum Laufen zu bringenDas Display kost nix (Aus Fundus defekter Telefone)
Das Display hat ganz viele Zeilen für Text
Quelle: http://www.frickelfritze.de/raspberry-m50530/index.html
Fertiger Blog hierzu:
http://hiwix.blogspot.de/2014/12/display-samsung-0282a-controller-m50530.html
Pin Belegung:
Pin Bez. Raspberry Bedeutung
1 GND nc
2 D0 nc
3 D1 nc
4 D2 nc
5 D3 nc
6 D4 Pin 22 GPIO25
7 D5 Pin 18 GPIO24
8 D6 Pin 16 GPIO23
9 D7 Pin 12 GPIO18
10 EX Pin 15 GPIO22
11 RW Pin 6
12 I/OC2 Pin 24 GPIO8
13 I/OC1 Pin 26 GPIO7
14 Kontrast: ca 8V
15 5V Pin 2
16 GND Pin 6
Quellen:
http://www.mikrocontroller.net/attachment/11703/LCD_8x24.inc
https://github.com/marioabajo/Lcd50530
http://www.hanneslux.de/avr/zuenduhr/LCD_8x24.inc

Keine Kommentare:
Kommentar veröffentlichen