SlideShare a Scribd company logo
1 of 6
Download to read offline
How to use all the GPIO on
Beaglebone Black in Python
GPIO include I/O, PWM, ADC, I2C, SPI, and UART
Meng Cao
8 November 2013
Summary
Bealgebone Black original using BoneScript, which is similar to Java. Usually we use C
for hardware programming. Python is a programming language which does much
better on programming and debugging than C. So, this application note will teach
about how to write programs using python. Also, the program would be able to control
all the hardware through GPIO, PWM, ADC.
Introduction
When doing complex project, people usually thing about get a microcontroller to
do all the controls and calculations. However microcontroller needs to involved PCB
design, also need protection circuit designed. Raspberry Pi is an option which has the
microcontroller on the board with other basic devices such as USB, Ethernet, and video
output. Texas Instrument has a similar product called Beaglebone. The newest version
of Beaglebone is Beaglebone Black. Compare to Raspberry Pi, the Beaglebone Black
has more GPIO pins, build in HDMI, also much more powerful processor. Both product
can run Linux as the on board operation system, which means, you can running almost
any language you want. This application not going to talk about using python as the
program language.
Things we need
1. Beaglebone Black
2. Python and libraries
3. Using libraries for GPIO,PWM,ADC
4. Setup SPI drivers on Beaglebone Black
5. Using library for SPI
Setup Beaglebone Black
The first step is setup the Beaglebone Black if you have one in your hand.
Beaglebone Black communicate with computers using USB cable. It need drivers to be
installed on the computer. The reason using driver is because the driver setup an IP
address for Beaglebone Black even though it only connected through USB. In that way
you can SSH to Beaglebone just like connect to a Linux server using SSH.
1 Connect Beaglebone to PC. An extra drive called “BeagleBone Getting Started”
appears in computer. Run the drivers under “Drivers” folder. “BONE_D64” for x64
windows or “BONE_DRV” for x32 windows.
2 Browse Beaglebone Black. Type “192.168.7.2” into address of your browser. (Avoid
to use Internet Explorer, may not working properly). You should see the following page.
3 Update on board Operation System. (This step can be skipped) Download the latest
software from http://beagleboard.org/latest-images. Unzip it and write the image to
SD card. Insert SD card into Beaglebone Black, hold USER/BOOT button when start
Beaglebone Black. Wait until all 4 LEDs be lit solid. It can take up to 45 mins.
For more detail, go to http://beagleboard.org/Getting%20Started.
4 SSH to Beaglebone Black. Two ways to SSH to Beaglebone Black. One is using
“GateOne SSH” on the webpage of step 2.
Other options is using third party SSH software such as PuTTY.
Use the username “root”, leave the password blank.
You already connected successfully to your Beaglebone Black. The system running on
Beaglebone Black is a distribution of Linux called Angstrom. You can also install
Ubuntu or Debian on board.
Python Library
Linux usually has build-in python. If we want to control all the GPIO using python,
we need to find a GPIO library for python. There are several GPIO libraries on the
internet for Python. PyBBIO and Adafruit_BBIO are most commonly used. In this
application note, will talk about how to install Adafruit_BBIO. Internet are required for
installation.
Adafruit_BBIO:
http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/
PyBBIO: https://github.com/alexanderhiam/PyBBIO/wiki
1 Install and Update Python. When you get SSH to Beaglebone Black, run the following
command.
2 Test Installation of library. Run the following command.
You should see something similar to the following
Up to here, the we already have the library required for GPIO.
Using GPIO, ADC, PWM in Python
Download Beaglebone Black System Reference Manual as a reference of the pin
mode. https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SRM.pdf
1 GPIO. For using GPIO, you need to include following line in the front of your python
program.
Output
Input
Edge detect
opkg update && opkg install python-pip python-setuptools python-smbus
pip install Adafruit_BBIO
python -c "import Adafruit_BBIO.GPIO as GPIO; print GPIO"
<module 'Adafruit_BBIO.GPIO' from '/usr/local/lib/python2.7/dist-packages/Adafruit_BBIO/GPIO.so'>
import Adafruit_BBIO.GPIO as GPIO
GPIO.setup(“Pin_Name”, GPIO.OUT) #Pin_Name such as P8_29, or GPIO2_1
GPIO.output(“Pin_Name”,GPIO.HIGH) #GPIO.HIGH for high or GPIO.LOW for low
GPIO.setup(“Pin_Name”, GPIO.IN) #Pin_Name such as P8_29, or GPIO2_1
Input = GPIO.output(“Pin_Name”) #Input = True when High, False when Low
GPIO.add_event_detect(“Pin_Name”, GPIO.RISING)
# GPIO.RISING for rising edge, GPIO.FALLING) for Falling edge
Detect = GPIO.event_detected(“Ping_Name”)
#Detect = True when detect the rising or falling edge
More
2 PWM. For using PWM, you need to include following line in the front of your python
program.
Start/Stop
Set duty cycle or frequency
3 ADC. Bealgebone Black has 7 ADC pin build in.Check System Reference Manual for
Pin numbers. For using ADC, you need to include following line in the front of your
python program.
Read raw value from the pin
Read voltage. ADC range from 0 to 1.8V
4 Adafruit_BBIO also has some other libraries for I2C, UART and SPI.
http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/
help(GPIO) # for other command in GPIO library
import Adafruit_BBIO.PWM as PWM
PWM.start(“Pin_Name”, Duty_Cycle) #Duty_Cycle from 0 to 100
PWM.stop(“Pin_Name”)
PWM.set_duty_cycle(“Pin_Name”, Duty_Cycle) #Duty_Cycle from 0 to 100
PWM.set_frenquency(“Pin_Name”, Frequency) #Frequecy
import Adafruit_BBIO.ADC as ADC
ADC.setup()
Value = ADC.read_raw(“Pin_Name”)
Value = ADC.read(“Pin_Name”) # the read function return a 0 to 1 value
Voltage = Value * 1.8

More Related Content

What's hot

Single Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi BasicsSingle Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi BasicsEueung Mulyana
 
Introduction To The Beagleboard
Introduction To The BeagleboardIntroduction To The Beagleboard
Introduction To The BeagleboardNeHal VeRma
 
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)Avansa Mid- en Zuidwest
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentCorley S.r.l.
 
Building the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry PiBuilding the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry PiNeil Broers
 
Java Device I/O at Raspberry PI to Build a Candy Vending Machine
Java Device I/O at Raspberry PI to Build a Candy Vending MachineJava Device I/O at Raspberry PI to Build a Candy Vending Machine
Java Device I/O at Raspberry PI to Build a Candy Vending MachineJeff Prestes
 
My presentation raspberry pi
My presentation raspberry piMy presentation raspberry pi
My presentation raspberry piHusainBhaldar21
 
BeagleBone Black Using Python
BeagleBone Black Using PythonBeagleBone Black Using Python
BeagleBone Black Using PythonSai Viswanath
 
Taking the BeagleBone Cookbook recipes beyond BeagleBone Black
Taking the BeagleBone Cookbook recipes beyond BeagleBone BlackTaking the BeagleBone Cookbook recipes beyond BeagleBone Black
Taking the BeagleBone Cookbook recipes beyond BeagleBone BlackDrew Fustini
 
Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014Mandeesh Singh
 
Raspberry Pi (Introduction)
Raspberry Pi (Introduction)Raspberry Pi (Introduction)
Raspberry Pi (Introduction)Mandeesh Singh
 
Beagle bone black by Boddukuri venkata saiteja
Beagle bone black  by Boddukuri venkata saitejaBeagle bone black  by Boddukuri venkata saiteja
Beagle bone black by Boddukuri venkata saitejaSai Charan
 
Hands On Embedded Linux with BeagleBone Black
Hands On Embedded Linux with BeagleBone BlackHands On Embedded Linux with BeagleBone Black
Hands On Embedded Linux with BeagleBone BlackDaniele Costarella
 
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick NeshRaspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick NeshTE4P
 
Python games (pygames)
Python games (pygames)Python games (pygames)
Python games (pygames)Ahmed Alyazji
 

What's hot (20)

Single Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi BasicsSingle Board Computers & Raspberry Pi Basics
Single Board Computers & Raspberry Pi Basics
 
Introduction To The Beagleboard
Introduction To The BeagleboardIntroduction To The Beagleboard
Introduction To The Beagleboard
 
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)DigiPinguïns: demo Raspberry Pi (Koen De Smet)
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
 
Raspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application DevelopmentRaspberry Pi - HW/SW Application Development
Raspberry Pi - HW/SW Application Development
 
Building the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry PiBuilding the Internet of Things with Raspberry Pi
Building the Internet of Things with Raspberry Pi
 
Java Device I/O at Raspberry PI to Build a Candy Vending Machine
Java Device I/O at Raspberry PI to Build a Candy Vending MachineJava Device I/O at Raspberry PI to Build a Candy Vending Machine
Java Device I/O at Raspberry PI to Build a Candy Vending Machine
 
My presentation raspberry pi
My presentation raspberry piMy presentation raspberry pi
My presentation raspberry pi
 
Feature satip4
Feature satip4Feature satip4
Feature satip4
 
Feature satip4
Feature satip4Feature satip4
Feature satip4
 
Raspberry pi
Raspberry piRaspberry pi
Raspberry pi
 
BeagleBone Black Using Python
BeagleBone Black Using PythonBeagleBone Black Using Python
BeagleBone Black Using Python
 
Beagle board
Beagle boardBeagle board
Beagle board
 
Taking the BeagleBone Cookbook recipes beyond BeagleBone Black
Taking the BeagleBone Cookbook recipes beyond BeagleBone BlackTaking the BeagleBone Cookbook recipes beyond BeagleBone Black
Taking the BeagleBone Cookbook recipes beyond BeagleBone Black
 
Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014Raspberry Pi Free Session - 20_09_2014
Raspberry Pi Free Session - 20_09_2014
 
Raspberry Pi (Introduction)
Raspberry Pi (Introduction)Raspberry Pi (Introduction)
Raspberry Pi (Introduction)
 
Beagle bone black by Boddukuri venkata saiteja
Beagle bone black  by Boddukuri venkata saitejaBeagle bone black  by Boddukuri venkata saiteja
Beagle bone black by Boddukuri venkata saiteja
 
Hands On Embedded Linux with BeagleBone Black
Hands On Embedded Linux with BeagleBone BlackHands On Embedded Linux with BeagleBone Black
Hands On Embedded Linux with BeagleBone Black
 
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick NeshRaspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
Raspberry JAM 1 - Setup Raspberry Pi with Raspbian -Vick Nesh
 
Python games (pygames)
Python games (pygames)Python games (pygames)
Python games (pygames)
 
BeagleBone Workshop
BeagleBone WorkshopBeagleBone Workshop
BeagleBone Workshop
 

Viewers also liked

We Have Seen His Star
We Have Seen His StarWe Have Seen His Star
We Have Seen His StarBea Aguenza
 
Sports Team Marketing Webinar
Sports Team Marketing Webinar Sports Team Marketing Webinar
Sports Team Marketing Webinar SimplyCast
 
Resultados cuartos de final
Resultados cuartos de finalResultados cuartos de final
Resultados cuartos de finalLiga Torneo
 
사설토토사이트〴働〴DßM777..ㄈØM〴働〴사설토토사이트
사설토토사이트〴働〴DßM777..ㄈØM〴働〴사설토토사이트사설토토사이트〴働〴DßM777..ㄈØM〴働〴사설토토사이트
사설토토사이트〴働〴DßM777..ㄈØM〴働〴사설토토사이트baccarat02
 
RESUME - NWAY NWAY
RESUME - NWAY NWAYRESUME - NWAY NWAY
RESUME - NWAY NWAYNway Nway
 
HOW TO HACK GIRLFRIEND HANGOUTS
HOW TO HACK GIRLFRIEND HANGOUTS HOW TO HACK GIRLFRIEND HANGOUTS
HOW TO HACK GIRLFRIEND HANGOUTS Margaret_Anderson
 
HOW TO HACK HANGOUTS MESSAGES WITHOUT THE PHONE
HOW TO HACK HANGOUTS MESSAGES WITHOUT THE PHONE HOW TO HACK HANGOUTS MESSAGES WITHOUT THE PHONE
HOW TO HACK HANGOUTS MESSAGES WITHOUT THE PHONE Margaret_Anderson
 
HOW TO HACK MY WIFES HANGOUTS
HOW TO HACK MY WIFES HANGOUTS HOW TO HACK MY WIFES HANGOUTS
HOW TO HACK MY WIFES HANGOUTS Margaret_Anderson
 

Viewers also liked (12)

We Have Seen His Star
We Have Seen His StarWe Have Seen His Star
We Have Seen His Star
 
R
RR
R
 
Sports Team Marketing Webinar
Sports Team Marketing Webinar Sports Team Marketing Webinar
Sports Team Marketing Webinar
 
Ahumado
AhumadoAhumado
Ahumado
 
Resultados cuartos de final
Resultados cuartos de finalResultados cuartos de final
Resultados cuartos de final
 
사설토토사이트〴働〴DßM777..ㄈØM〴働〴사설토토사이트
사설토토사이트〴働〴DßM777..ㄈØM〴働〴사설토토사이트사설토토사이트〴働〴DßM777..ㄈØM〴働〴사설토토사이트
사설토토사이트〴働〴DßM777..ㄈØM〴働〴사설토토사이트
 
RESUME - NWAY NWAY
RESUME - NWAY NWAYRESUME - NWAY NWAY
RESUME - NWAY NWAY
 
Central de riesgo
Central de riesgoCentral de riesgo
Central de riesgo
 
PPS Orchard Project
PPS Orchard ProjectPPS Orchard Project
PPS Orchard Project
 
HOW TO HACK GIRLFRIEND HANGOUTS
HOW TO HACK GIRLFRIEND HANGOUTS HOW TO HACK GIRLFRIEND HANGOUTS
HOW TO HACK GIRLFRIEND HANGOUTS
 
HOW TO HACK HANGOUTS MESSAGES WITHOUT THE PHONE
HOW TO HACK HANGOUTS MESSAGES WITHOUT THE PHONE HOW TO HACK HANGOUTS MESSAGES WITHOUT THE PHONE
HOW TO HACK HANGOUTS MESSAGES WITHOUT THE PHONE
 
HOW TO HACK MY WIFES HANGOUTS
HOW TO HACK MY WIFES HANGOUTS HOW TO HACK MY WIFES HANGOUTS
HOW TO HACK MY WIFES HANGOUTS
 

Similar to Meng

ChromePad - Chromium OS ThinkPad X220
ChromePad - Chromium OS ThinkPad X220ChromePad - Chromium OS ThinkPad X220
ChromePad - Chromium OS ThinkPad X220AndrewWright224
 
ChromePad - Chromium OS for ThinkPad
ChromePad - Chromium OS for ThinkPadChromePad - Chromium OS for ThinkPad
ChromePad - Chromium OS for ThinkPadAndrewWright224
 
manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfssuserc5ee4c
 
Raspi_TOR_Access_Point_BenMoore
Raspi_TOR_Access_Point_BenMooreRaspi_TOR_Access_Point_BenMoore
Raspi_TOR_Access_Point_BenMooreBenjamin Moore
 
Tac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PITac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PICliff Samuels Jr.
 
Introduction to Raspberry Pi
Introduction to Raspberry PiIntroduction to Raspberry Pi
Introduction to Raspberry PiIsuru Jayarathne
 
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi [Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi Tomomi Imura
 
BeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream ComponentsBeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream ComponentsGlobalLogic Ukraine
 
ScratchGPIO, Raspberry Pi & BerryClip
ScratchGPIO, Raspberry Pi & BerryClipScratchGPIO, Raspberry Pi & BerryClip
ScratchGPIO, Raspberry Pi & BerryClipDavid Dryden
 
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)Patricia Aas
 
Connected hardware for Software Engineers 101
Connected hardware for Software Engineers 101Connected hardware for Software Engineers 101
Connected hardware for Software Engineers 101Pance Cavkovski
 
PyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_AyanPyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_AyanAyan Pahwa
 
Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014Mandeesh Singh
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry PiLloydMoore
 
DeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonDeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonGabriel Arnautu
 

Similar to Meng (20)

ChromePad - Chromium OS ThinkPad X220
ChromePad - Chromium OS ThinkPad X220ChromePad - Chromium OS ThinkPad X220
ChromePad - Chromium OS ThinkPad X220
 
ChromePad - Chromium OS for ThinkPad
ChromePad - Chromium OS for ThinkPadChromePad - Chromium OS for ThinkPad
ChromePad - Chromium OS for ThinkPad
 
manual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdfmanual_2020_Cyber Physical System.pdf
manual_2020_Cyber Physical System.pdf
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Raspi_TOR_Access_Point_BenMoore
Raspi_TOR_Access_Point_BenMooreRaspi_TOR_Access_Point_BenMoore
Raspi_TOR_Access_Point_BenMoore
 
Tac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PITac Presentation October 72014- Raspberry PI
Tac Presentation October 72014- Raspberry PI
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Introduction to Raspberry Pi
Introduction to Raspberry PiIntroduction to Raspberry Pi
Introduction to Raspberry Pi
 
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi [Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
[Forward4 Webinar 2016] Building IoT Prototypes w/ Raspberry Pi
 
BeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream ComponentsBeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream Components
 
ScratchGPIO, Raspberry Pi & BerryClip
ScratchGPIO, Raspberry Pi & BerryClipScratchGPIO, Raspberry Pi & BerryClip
ScratchGPIO, Raspberry Pi & BerryClip
 
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)
Linux Security APIs and the Chromium Sandbox (SwedenCpp Meetup 2017)
 
Lab manual
Lab manualLab manual
Lab manual
 
Connected hardware for Software Engineers 101
Connected hardware for Software Engineers 101Connected hardware for Software Engineers 101
Connected hardware for Software Engineers 101
 
Feature satip4
Feature satip4Feature satip4
Feature satip4
 
PyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_AyanPyCon_India_2017_MicroPython_Ayan
PyCon_India_2017_MicroPython_Ayan
 
Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014Raspberry Pi Session - 22_11_2014
Raspberry Pi Session - 22_11_2014
 
Starting Raspberry Pi
Starting Raspberry PiStarting Raspberry Pi
Starting Raspberry Pi
 
DeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonDeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel Edison
 
Feature satip4
Feature satip4Feature satip4
Feature satip4
 

Recently uploaded

Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 

Recently uploaded (20)

Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 

Meng

  • 1. How to use all the GPIO on Beaglebone Black in Python GPIO include I/O, PWM, ADC, I2C, SPI, and UART Meng Cao 8 November 2013 Summary Bealgebone Black original using BoneScript, which is similar to Java. Usually we use C for hardware programming. Python is a programming language which does much better on programming and debugging than C. So, this application note will teach about how to write programs using python. Also, the program would be able to control all the hardware through GPIO, PWM, ADC.
  • 2. Introduction When doing complex project, people usually thing about get a microcontroller to do all the controls and calculations. However microcontroller needs to involved PCB design, also need protection circuit designed. Raspberry Pi is an option which has the microcontroller on the board with other basic devices such as USB, Ethernet, and video output. Texas Instrument has a similar product called Beaglebone. The newest version of Beaglebone is Beaglebone Black. Compare to Raspberry Pi, the Beaglebone Black has more GPIO pins, build in HDMI, also much more powerful processor. Both product can run Linux as the on board operation system, which means, you can running almost any language you want. This application not going to talk about using python as the program language. Things we need 1. Beaglebone Black 2. Python and libraries 3. Using libraries for GPIO,PWM,ADC 4. Setup SPI drivers on Beaglebone Black 5. Using library for SPI Setup Beaglebone Black The first step is setup the Beaglebone Black if you have one in your hand. Beaglebone Black communicate with computers using USB cable. It need drivers to be installed on the computer. The reason using driver is because the driver setup an IP address for Beaglebone Black even though it only connected through USB. In that way you can SSH to Beaglebone just like connect to a Linux server using SSH. 1 Connect Beaglebone to PC. An extra drive called “BeagleBone Getting Started” appears in computer. Run the drivers under “Drivers” folder. “BONE_D64” for x64 windows or “BONE_DRV” for x32 windows.
  • 3. 2 Browse Beaglebone Black. Type “192.168.7.2” into address of your browser. (Avoid to use Internet Explorer, may not working properly). You should see the following page. 3 Update on board Operation System. (This step can be skipped) Download the latest software from http://beagleboard.org/latest-images. Unzip it and write the image to SD card. Insert SD card into Beaglebone Black, hold USER/BOOT button when start Beaglebone Black. Wait until all 4 LEDs be lit solid. It can take up to 45 mins. For more detail, go to http://beagleboard.org/Getting%20Started. 4 SSH to Beaglebone Black. Two ways to SSH to Beaglebone Black. One is using “GateOne SSH” on the webpage of step 2.
  • 4. Other options is using third party SSH software such as PuTTY. Use the username “root”, leave the password blank. You already connected successfully to your Beaglebone Black. The system running on Beaglebone Black is a distribution of Linux called Angstrom. You can also install Ubuntu or Debian on board. Python Library Linux usually has build-in python. If we want to control all the GPIO using python, we need to find a GPIO library for python. There are several GPIO libraries on the internet for Python. PyBBIO and Adafruit_BBIO are most commonly used. In this application note, will talk about how to install Adafruit_BBIO. Internet are required for installation. Adafruit_BBIO: http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/
  • 5. PyBBIO: https://github.com/alexanderhiam/PyBBIO/wiki 1 Install and Update Python. When you get SSH to Beaglebone Black, run the following command. 2 Test Installation of library. Run the following command. You should see something similar to the following Up to here, the we already have the library required for GPIO. Using GPIO, ADC, PWM in Python Download Beaglebone Black System Reference Manual as a reference of the pin mode. https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SRM.pdf 1 GPIO. For using GPIO, you need to include following line in the front of your python program. Output Input Edge detect opkg update && opkg install python-pip python-setuptools python-smbus pip install Adafruit_BBIO python -c "import Adafruit_BBIO.GPIO as GPIO; print GPIO" <module 'Adafruit_BBIO.GPIO' from '/usr/local/lib/python2.7/dist-packages/Adafruit_BBIO/GPIO.so'> import Adafruit_BBIO.GPIO as GPIO GPIO.setup(“Pin_Name”, GPIO.OUT) #Pin_Name such as P8_29, or GPIO2_1 GPIO.output(“Pin_Name”,GPIO.HIGH) #GPIO.HIGH for high or GPIO.LOW for low GPIO.setup(“Pin_Name”, GPIO.IN) #Pin_Name such as P8_29, or GPIO2_1 Input = GPIO.output(“Pin_Name”) #Input = True when High, False when Low GPIO.add_event_detect(“Pin_Name”, GPIO.RISING) # GPIO.RISING for rising edge, GPIO.FALLING) for Falling edge Detect = GPIO.event_detected(“Ping_Name”) #Detect = True when detect the rising or falling edge
  • 6. More 2 PWM. For using PWM, you need to include following line in the front of your python program. Start/Stop Set duty cycle or frequency 3 ADC. Bealgebone Black has 7 ADC pin build in.Check System Reference Manual for Pin numbers. For using ADC, you need to include following line in the front of your python program. Read raw value from the pin Read voltage. ADC range from 0 to 1.8V 4 Adafruit_BBIO also has some other libraries for I2C, UART and SPI. http://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/ help(GPIO) # for other command in GPIO library import Adafruit_BBIO.PWM as PWM PWM.start(“Pin_Name”, Duty_Cycle) #Duty_Cycle from 0 to 100 PWM.stop(“Pin_Name”) PWM.set_duty_cycle(“Pin_Name”, Duty_Cycle) #Duty_Cycle from 0 to 100 PWM.set_frenquency(“Pin_Name”, Frequency) #Frequecy import Adafruit_BBIO.ADC as ADC ADC.setup() Value = ADC.read_raw(“Pin_Name”) Value = ADC.read(“Pin_Name”) # the read function return a 0 to 1 value Voltage = Value * 1.8