Metainformationen zur Seite
  •  

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
computer:raspberrypi:gpio [2013/07/12 00:50]
ristigl [Ansprechen mit Python]
computer:raspberrypi:gpio [2018/03/16 21:11] (aktuell)
Zeile 2: Zeile 2:
  
 <note warning>​Do not use voltage levels greater than 3.3V, Raspberry pi doesn´t support 5V and doesn'​t have an over-voltage protection.</​note>​ <note warning>​Do not use voltage levels greater than 3.3V, Raspberry pi doesn´t support 5V and doesn'​t have an over-voltage protection.</​note>​
 +Quelle: https://​sites.google.com/​site/​semilleroadt/​raspberry-pi-tutorials/​gpio
  
-{{:​computer:​raspberrypi:​gpio-revision1.png}} +{{:​computer:​raspberrypi:​gpio-revision1.png?300}} 
-{{:​computer:​raspberrypi:​gpio-revision2.png}}+{{:​computer:​raspberrypi:​gpio-revision2.png?300}}
  
-https://sites.google.com/site/semilleroadt/​raspberry-pi-tutorials/​gpio+ 
 + 
 +Quelle: http://www.doctormonk.com/2013/02/​raspberry-pi-and-breadboard-raspberry.html 
 + 
 +Sehr sinnvoll für ein möglichst sicheres basteln ist diese Idee: 
 + 
 +{{:​computer:​raspberrypi:​leaf_-_web.jpg}} 
 +{{:​computer:​raspberrypi:​raspberry_leaf_r2.png}}
  
 ===== Pegelanpassung ===== ===== Pegelanpassung =====
-{{ :​computer:​raspberrypi:​pipegelwandler.png}}Manche Geräte müssen mit einer 5V-Logik angesteuert werden. Der RaspberryPi nutzt eine 3,3V-Logik. Hierzu lassen sich die Pegel anpassen.+Quelle: http://​www.rn-wissen.de/​index.php/​Raspberry_PI:​_GPIO 
 + 
 +{{ :​computer:​raspberrypi:​pipegelwandler.png?321}}Manche Geräte müssen mit einer 5V-Logik angesteuert werden. Der RaspberryPi nutzt eine 3,3V-Logik. Hierzu lassen sich die Pegel anpassen.
  
 Der nebenstehende Schaltplan zeigt eine Möglichkeit anhand von 2 Transistoren den Ausgang auf 5V anzuheben. Der nebenstehende Schaltplan zeigt eine Möglichkeit anhand von 2 Transistoren den Ausgang auf 5V anzuheben.
Zeile 17: Zeile 27:
  
  
-===== Ansprechen ​mit Python ​=====+===== Ansprechen ​über die Shell ===== 
 +Um eine LED mithilfe eines Raspberry Pis zum Blinken zu bringen, benötigt man zu allererst WiringPi.
  
-{{ :computer:​raspberrypi:​slice-schematic-11-300x225.png}}+  wget http://project-downloads.drogon.net/​files/​wiringPi.tgz
  
-Quellehttp://​openmicros.org/​index.php/​articles/​94-ciseco-product-documentation/​raspberry-pi/​217-getting-started-with-raspberry-pi-gpio-and-python+Das Programm muss nun entpackt, kompiliert und installiert werden:
  
 <​code>​ <​code>​
-wget http://​pypi.python.org/​packages/​source/​R/​RPi.GPIO/​RPi.GPIO-0.1.0.tar.gz +tar xfz wiringPi.tgz 
-tar zxf RPi.GPIO-0.1.0.tar.gz +cd wiringPi/​wiringPi 
-cd RPi.GPIO-0.1.0 +make 
-sudo python setup.py install+make install 
 +cd ../gpio 
 +make clean
 </​code>​ </​code>​
  
-Beipielcode:+Ist das Programm installiert,​ so lassen sich Pins wie folgt ansprechen: 
 + 
 +  /​usr/​local/​bin/​gpio -g mode 23 out 
 +  /​usr/​local/​bin/​gpio -g write 23 1 
 + 
 +===== Ansprechen mit Python ===== 
 + 
 +{{ :​computer:​raspberrypi:​slice-schematic-11-300x225.png}} 
 <​code>​ <​code>​
 +apt-get install python-rpi.gpio
 +</​code>​
 +
 +Beipielcode:​ https://​code.google.com/​p/​raspberry-gpio-python/​wiki/​BasicUsage
 +<code python>
 import RPi.GPIO as GPIO import RPi.GPIO as GPIO
 +GPIO.setmode(GPIO.BCM)
 +
 GPIO.setup(18,​ GPIO.OUT) GPIO.setup(18,​ GPIO.OUT)
 GPIO.output(18,​ False) GPIO.output(18,​ False)
Zeile 42: Zeile 70:
 </​code>​ </​code>​
  
 +===== Pull-Up und Pull-Down =====
 +Quelle: https://​code.google.com/​p/​raspberry-gpio-python/​wiki/​Inputs
  
 +"If you do not have the input pin connected to anything, it will '​float'​. In other words, the value that is read in is undefined because it is not connected to anything until you press a button or switch. It will probably change value a lot as a result of receiving mains interference.
 +
 +To get round this, we use a pull up or a pull down resistor. In this way, the default value of the input can be set. It is possible to have pull up/down resistors in hardware and using software. In hardware, a 10K resistor between the input channel and 3.3V (pull-up) or 0V (pull-down) is commonly used. The RPi.GPIO module allows you to configure the Broadcom SOC to do this in software:"​
 +
 +  GPIO.setup(channel,​ GPIO.IN, pull_up_down=GPIO.PUD_UP)
 +or
 +  GPIO.setup(channel,​ GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
 +
 +Problem: SDA und SCL-Pins funktionieren nicht wie erwarten:
 +
 +Quelle: http://​raspberrypi.stackexchange.com/​questions/​4919/​unable-to-read-from-sda-scl-as-gpio
 +
 +"SDA and SCL pins have external 1k8 pull-up resistors connected. This is indeed because they are intended for I²C usage (which requires them). Unfortunately,​ since they are external, they can't be disabled in software.
 +
 +Having pull-up resistors means that default state of the pin in HIGH, unless they are pulled to ground."​
 +
 +
 +===== Problem: Prellen =====
 +{{ :​computer:​raspberrypi:​entprellen.png}}
 +Wenn man einen Taster Anschließt,​ so kommt es beim Betätigen zum Prellen (Siehe Abbildung).
 +
 +Quelle: http://​www.mikrocontroller.net/​articles/​Entprellung
 +
 +===== Portexpander =====
 +
 +Kontroller-Chip,​ um 16 Ausgänge mit 2 Leitungen anzusteuern:​
 +
 +http://​www.pollin.de/​shop/​dt/​MDY4ODk4OTk-/​Bauelemente_Bauteile/​Aktive_Bauelemente/​IC/​MCP23S17_E_SP.html
 +
 +https://​ex.ploit.ws/​themagpi/​The-MagPi-issue-13-en.pdf Seite 11:
 +
 +
 +Laden der Treiber zulassen:
 +
 +In **/​etc/​modprobe.d/​raspi-blacklist.conf** den Eintrag für **i2c-bcm2708** einkommentieren.
 +In **/​etc/​modules** einen Zeile mit **i2c-dev** anlegen.
 +
 +Installieren der Tools zur Ansteuerung:​
 +<​code>​
 +sudo apt-get update
 +sudo apt-get install python-smbus
 +sudo apt-get install i2c-tools
 +sudo adduser pi i2c
 +sudo reboot
 +sudo i2cdetect -y 1
 +</​code>​
  
 +...