Metainformationen zur Seite
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
computer:raspberrypi:displays [2013/06/21 18:04] ristigl [mini-Displays] |
computer:raspberrypi:displays [2018/03/16 21:11] (aktuell) |
||
|---|---|---|---|
| Zeile 10: | Zeile 10: | ||
| * http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display | * http://www.schnatterente.net/technik/raspberry-pi-32-zeichen-hitachi-hd44780-display | ||
| * Skirpt (anpassen an die eigenen Pins!): http://www.schnatterente.net/code/raspberrypi/displaytest.py | * Skirpt (anpassen an die eigenen Pins!): http://www.schnatterente.net/code/raspberrypi/displaytest.py | ||
| - | * | + | {{ :computer:raspberrypi:raspberry-pi-display-aufbau.png}} |
| - | Angepasstes Skript: | ||
| <code python> | <code python> | ||
| #!/usr/bin/python | #!/usr/bin/python | ||
| import time | import time | ||
| import RPi.GPIO as GPIO | import RPi.GPIO as GPIO | ||
| - | import sys | ||
| # Zuordnung der GPIO Pins (ggf. anpassen) | # Zuordnung der GPIO Pins (ggf. anpassen) | ||
| - | DISPLAY_RS = 18 | + | DISPLAY_RS = 7 |
| - | DISPLAY_E = 23 | + | DISPLAY_E = 8 |
| - | DISPLAY_DATA4 = 24 | + | DISPLAY_DATA4 = 25 |
| - | DISPLAY_DATA5 = 25 | + | DISPLAY_DATA5 = 24 |
| - | DISPLAY_DATA6 = 8 | + | DISPLAY_DATA6 = 23 |
| - | DISPLAY_DATA7 = 7 | + | DISPLAY_DATA7 = 18 |
| - | DISPLAY_WIDTH = 8 # Zeichen je Zeile | + | DISPLAY_WIDTH = 16 # Zeichen je Zeile |
| - | DISPLAY_LINE_1 = 0x80 # Adresse der ersten Display Zeile | + | DISPLAY_LINE_1 = 0x80 # Adresse der ersten Display Zeile |
| - | DISPLAY_LINE_2 = 0xC0 # Adresse der zweiten Display Zeile | + | DISPLAY_LINE_2 = 0xC0 # Adresse der zweiten Display Zeile |
| DISPLAY_CHR = True | DISPLAY_CHR = True | ||
| DISPLAY_CMD = False | DISPLAY_CMD = False | ||
| Zeile 39: | Zeile 37: | ||
| def main(): | def main(): | ||
| - | GPIO.setwarnings(False) | + | GPIO.setmode(GPIO.BCM) |
| - | GPIO.setmode(GPIO.BCM) | + | GPIO.setup(DISPLAY_E, GPIO.OUT) |
| - | GPIO.setup(DISPLAY_E, GPIO.OUT) | + | GPIO.setup(DISPLAY_RS, GPIO.OUT) |
| - | GPIO.setup(DISPLAY_RS, GPIO.OUT) | + | GPIO.setup(DISPLAY_DATA4, GPIO.OUT) |
| - | GPIO.setup(DISPLAY_DATA4, GPIO.OUT) | + | GPIO.setup(DISPLAY_DATA5, GPIO.OUT) |
| - | GPIO.setup(DISPLAY_DATA5, GPIO.OUT) | + | GPIO.setup(DISPLAY_DATA6, GPIO.OUT) |
| - | GPIO.setup(DISPLAY_DATA6, GPIO.OUT) | + | GPIO.setup(DISPLAY_DATA7, GPIO.OUT) |
| - | GPIO.setup(DISPLAY_DATA7, GPIO.OUT) | + | |
| + | display_init() | ||
| + | |||
| + | lcd_byte(DISPLAY_LINE_1, DISPLAY_CMD) | ||
| + | lcd_string("Schnatterente") | ||
| + | lcd_byte(DISPLAY_LINE_2, DISPLAY_CMD) | ||
| + | lcd_string("Nak nak nak!") | ||
| + | |||
| + | time.sleep(5) | ||
| + | |||
| + | lcd_byte(DISPLAY_LINE_1, DISPLAY_CMD) | ||
| + | lcd_string("Dein Display") | ||
| + | lcd_byte(DISPLAY_LINE_2, DISPLAY_CMD) | ||
| + | lcd_string("funktioniert! :)") | ||
| + | |||
| + | time.sleep(5) | ||
| + | GPIO.cleanup() | ||
| - | if sys.argv[1]=="1": | ||
| - | lcd_byte(DISPLAY_LINE_1, DISPLAY_CMD) | ||
| - | lcd_string(sys.argv[2]) | ||
| - | elif sys.argv[1]=="2": | ||
| - | lcd_byte(DISPLAY_LINE_2, DISPLAY_CMD) | ||
| - | lcd_string(sys.argv[2]) | ||
| - | else: | ||
| - | display_init() | ||
| - | GPIO.cleanup() | ||
| def display_init(): | def display_init(): | ||
| - | lcd_byte(0x33,DISPLAY_CMD) | + | lcd_byte(0x33,DISPLAY_CMD) |
| - | lcd_byte(0x32,DISPLAY_CMD) | + | lcd_byte(0x32,DISPLAY_CMD) |
| - | lcd_byte(0x28,DISPLAY_CMD) | + | lcd_byte(0x28,DISPLAY_CMD) |
| - | lcd_byte(0x0C,DISPLAY_CMD) | + | lcd_byte(0x0C,DISPLAY_CMD) |
| - | lcd_byte(0x06,DISPLAY_CMD) | + | lcd_byte(0x06,DISPLAY_CMD) |
| - | lcd_byte(0x01,DISPLAY_CMD) | + | lcd_byte(0x01,DISPLAY_CMD) |
| def lcd_string(message): | def lcd_string(message): | ||
| - | message = message.ljust(DISPLAY_WIDTH," ") | + | message = message.ljust(DISPLAY_WIDTH," ") |
| - | for i in range(DISPLAY_WIDTH): | + | for i in range(DISPLAY_WIDTH): |
| - | lcd_byte(ord(message[i]),DISPLAY_CHR) | + | lcd_byte(ord(message[i]),DISPLAY_CHR) |
| def lcd_byte(bits, mode): | def lcd_byte(bits, mode): | ||
| - | GPIO.output(DISPLAY_RS, mode) | + | GPIO.output(DISPLAY_RS, mode) |
| - | GPIO.output(DISPLAY_DATA4, False) | + | GPIO.output(DISPLAY_DATA4, False) |
| - | GPIO.output(DISPLAY_DATA5, False) | + | GPIO.output(DISPLAY_DATA5, False) |
| - | GPIO.output(DISPLAY_DATA6, False) | + | GPIO.output(DISPLAY_DATA6, False) |
| - | GPIO.output(DISPLAY_DATA7, False) | + | GPIO.output(DISPLAY_DATA7, False) |
| - | if bits&0x10==0x10: | + | if bits&0x10==0x10: |
| - | GPIO.output(DISPLAY_DATA4, True) | + | GPIO.output(DISPLAY_DATA4, True) |
| - | if bits&0x20==0x20: | + | if bits&0x20==0x20: |
| - | GPIO.output(DISPLAY_DATA5, True) | + | GPIO.output(DISPLAY_DATA5, True) |
| - | if bits&0x40==0x40: | + | if bits&0x40==0x40: |
| - | GPIO.output(DISPLAY_DATA6, True) | + | GPIO.output(DISPLAY_DATA6, True) |
| - | if bits&0x80==0x80: | + | if bits&0x80==0x80: |
| - | GPIO.output(DISPLAY_DATA7, True) | + | GPIO.output(DISPLAY_DATA7, True) |
| - | time.sleep(E_DELAY) | + | time.sleep(E_DELAY) |
| - | GPIO.output(DISPLAY_E, True) | + | GPIO.output(DISPLAY_E, True) |
| - | time.sleep(E_PULSE) | + | time.sleep(E_PULSE) |
| - | GPIO.output(DISPLAY_E, False) | + | GPIO.output(DISPLAY_E, False) |
| - | time.sleep(E_DELAY) | + | time.sleep(E_DELAY) |
| - | GPIO.output(DISPLAY_DATA4, False) | + | GPIO.output(DISPLAY_DATA4, False) |
| - | GPIO.output(DISPLAY_DATA5, False) | + | GPIO.output(DISPLAY_DATA5, False) |
| - | GPIO.output(DISPLAY_DATA6, False) | + | GPIO.output(DISPLAY_DATA6, False) |
| - | GPIO.output(DISPLAY_DATA7, False) | + | GPIO.output(DISPLAY_DATA7, False) |
| - | if bits&0x01==0x01: | + | if bits&0x01==0x01: |
| - | GPIO.output(DISPLAY_DATA4, True) | + | GPIO.output(DISPLAY_DATA4, True) |
| - | if bits&0x02==0x02: | + | if bits&0x02==0x02: |
| - | GPIO.output(DISPLAY_DATA5, True) | + | GPIO.output(DISPLAY_DATA5, True) |
| - | if bits&0x04==0x04: | + | if bits&0x04==0x04: |
| - | GPIO.output(DISPLAY_DATA6, True) | + | GPIO.output(DISPLAY_DATA6, True) |
| - | if bits&0x08==0x08: | + | if bits&0x08==0x08: |
| - | GPIO.output(DISPLAY_DATA7, True) | + | GPIO.output(DISPLAY_DATA7, True) |
| - | time.sleep(E_DELAY) | + | time.sleep(E_DELAY) |
| - | GPIO.output(DISPLAY_E, True) | + | GPIO.output(DISPLAY_E, True) |
| - | time.sleep(E_PULSE) | + | time.sleep(E_PULSE) |
| - | GPIO.output(DISPLAY_E, False) | + | GPIO.output(DISPLAY_E, False) |
| - | time.sleep(E_DELAY) | + | time.sleep(E_DELAY) |
| if __name__ == '__main__': | if __name__ == '__main__': | ||
| - | main() | + | main() |
| </code> | </code> | ||
| - | Aufruf als "root"! | + | Kleines Skipt, um Daten von der Shell anzeigen zu können: [[computer:raspberrypi:programme:display_from_shell|]] |
| - | name.py 1|2 TEXT | + | |
| - | name.py c | + | |
| ==== Datenblätter ==== | ==== Datenblätter ==== | ||
| * {{:computer:raspberrypi:lcd-c0802-04.pdf|}} | * {{:computer:raspberrypi:lcd-c0802-04.pdf|}} | ||
| * | * | ||
| - | ===== kleine-Displays ===== | + | ===== Auto-Monitore ===== |
| - | Auto-Monitore, z.b.: | + | Z.B.: |
| * http://www.pollin.de/shop/dt/ODI5OTkzOTk-/HiFi_Car_HiFi_Video_TV/TV/Fernseher/17_8_cm_7_LCD_Monitor_PremiumBlue_Nova_M7.html | * http://www.pollin.de/shop/dt/ODI5OTkzOTk-/HiFi_Car_HiFi_Video_TV/TV/Fernseher/17_8_cm_7_LCD_Monitor_PremiumBlue_Nova_M7.html | ||
| * http://www.amazon.de/Iharbort-Zoll-Monitor-R%C3%BCckfahrkamera-monitor/dp/B00C09LVES/ref=lh_ni_t?ie=UTF8&psc=1&smid=A10J6HLB3153R2 | * http://www.amazon.de/Iharbort-Zoll-Monitor-R%C3%BCckfahrkamera-monitor/dp/B00C09LVES/ref=lh_ni_t?ie=UTF8&psc=1&smid=A10J6HLB3153R2 | ||
| - | Angeschlossen werden die Monitore über Cinch-Kabel | + | Angeschlossen werden die Monitore über Cinch-Kabel. |
| + | |||
| + | ==== Umbau von 12V auf 5V ==== | ||
| + | |||
| + | Die Monitore sind für den 12-Volt-Betrieb auselegt, da die meisten Autos mit der 12V-Spannung arbeiten. Beim RaspberryPi kann das ungünstig sein, denn hier arbeiten wir mit 5V. | ||
| + | |||
| + | Zwar werden die Monitore mit 12 von außen versorgt, der Betrieb erfolgt aber intern mit 5V. Also wird die 12V-Spannung, die auch unregelmäßiger sein kann als die Versorgung beim RaspberryPi auf 12V gedrosselt. Hierfür ist der kleine Chip XL1509 zuständig. Das Datenblatt (http://bbs.dianyuan.com/bbs/u/65/1617951209993662.pdf oder {{:computer:raspberrypi:xl1509.pdf|}}) ergibt, dass man 5V an den Pin 2 anlegen muss. | ||
| + | |||
| + | Zu beachten ist weiterhin, dass das Netzteil mehr Strom liefern muss. Mein Pi läuft zwar mit dem Monitor, beim Hereinstecken in die USB-Buchse bootet der Pi aber neu. Ich nutzte 5V mit 1A. | ||
| + | |||
| + | Quellen: | ||
| + | * http://www.raspberrypi.org/phpBB3/viewtopic.php?f=64&t=17651 | ||
| + | * http://www.wisegai.com/2012/11/29/raspberry-pi-using-a-3-5-tft-car-monitor-optional-powered-using-usb/ | ||
| + | * http://www.raspberrypi.org/phpBB3/viewtopic.php?f=64&t=17651&start=125 | ||
| + | |||
| + | |||