daros
-
Upload
david-gonzalez-gamboa -
Category
Documents
-
view
7 -
download
0
Transcript of daros
OverviewConnecting the Cobbler to a MCP3008Necessary PackagesPython ScriptRun ItDownload PDF
Home/Raspberry Pi/Analog Inputs for Raspberry Pi Using the MCP3008/Connecting the Cobbler to a MCP3008
Featured in this Guide
Full sized breadboard
$7.95 Add to CartHalf-size breadboard
$5.00 Add to CartPanel Mount 10K potentiometer (Breadboard Friendly)
$0.95 Add to CartBreadboard trim potentiometer
Analog Inputs for Raspberry Pi Using theMCP3008Convert analog inputs to digital and control audio volume
OverviewConnecting the Cobbler to a MCP3008Necessary PackagesPython ScriptRun It
Single PageDownload PDF
Feedback? Corrections?
Search the Adafruit Learning System
Connecting the Cobbler to a MCP3008 | Analog Inputs fo... http://learn.adafruit.com/reading-a-analog-in-and-control...
1 of 6 16/10/13 20:38
$1.25 Add to CartGPIO Ribbon Cable for Raspberry Pi
$2.95 Add to CartAdafruit Pi Box - Enclosure for Raspberry Pi Model A or B
$14.95 Add to CartAdafruit Assembled Pi Cobbler Breakout + Cable for Raspberry Pi
$7.95 Add to CartAdd all to Cart×
Out of Stock Notification
Your Name: Your E-mail:
Notify Me
Connecting the Cobbler to a MCP3008 Created by MikeySklar
Connecting the Cobbler to a MCP3008 | Analog Inputs fo... http://learn.adafruit.com/reading-a-analog-in-and-control...
2 of 6 16/10/13 20:38
To follow this tutorial you will need
MCP3008 DIP-package ADC converter chip10K trimer or panel mount potentiometerAdafruit Pi Cobbler - follow the tutorial to assemble itHalf or Full-size breadboardBreadboarding wires
And of course a working Raspberry Pi with Internet connection
Why we need an ADC
The Raspberry Pi computer does not have a way to read analog inputs. It's a digital-onlycomputer. Compare this to the Arduino, AVR or PIC microcontrollers that often have 6 or moreanalog inputs! Analog inputs are handy because many sensors are analog outputs, so we need away to make the Pi analog-friendly.
We'll do that by wiring up an MCP3008 chip to it. The MCP3008 acts like a 'bridge' betweendigital and analog. It has 8 analog inputs and the Pi can query it using 4 digital pins. That makesit a perfect addition to the Pi for integrating simple sensors like photocells, FSRsor potentiometers, thermistors, etc.!
Lets check the datasheet of the MCP3008 chip. On the first page in the lower right corner there'sa pinout diagram showing the names of the pins
Wiring Diagram
In order to read analog data we need to use the following pins: VDD (power), DGND (digitalground) to power the MCP3008 chip. We also need four 'SPI' data pins: DOUT (Data Out fromMCP3008), CLK (Clock pin), DIN (Data In from Raspberry Pi), and /CS (Chip Select). Finally ofcourse, a source of analog data, we'll be using the basic 10k trim pot.
Connecting the Cobbler to a MCP3008 | Analog Inputs fo... http://learn.adafruit.com/reading-a-analog-in-and-control...
3 of 6 16/10/13 20:38
The MCP3008 has a few more pins we need to connect: AGND (analog ground, used sometimesin precision circuitry, which this is not) connects to GND, and VREF (analog voltage reference,used for changing the 'scale' - we want the full scale so tie it to 3.3V)
Below is a wiring diagram. Connect the 3.3V cobbler pin to the left + rail and the GND pin to theright - rail. Connect the following pins for the MCP chip
MCP3008 VDD -> 3.3V (red)MCP3008 VREF -> 3.3V (red)MCP3008 AGND -> GND (black)MCP3008 CLK -> #18 (orange)MCP3008 DOUT -> #23 (yellow)MCP3008 DIN -> #24 (blue)MCP3008 CS -> #25 (violet)MCP3008 DGND -> GND (black)
Next connect up the potentiometer. Pin #1 (left) goes to GND (black), #2 (middle) connects toMCP3008 CH0 (analog input #0) with a gray wire, and #3 (right) connects to 3.3V (red)
Advanced users may note that the Raspberry Pi does have a hardware SPI interface (the cobblerpins are labeled MISO/MOSI/SCLK/CE0/CE1). The hardware SPI interface is super fast but notincluded in all distributions. For that reason we are using a bit banged SPI implementation so theSPI pins can be any of the raspberry pi's GPIOs (assuming you update the script).
< Overview Necessary Packages >
Connecting the Cobbler to a MCP3008 | Analog Inputs fo... http://learn.adafruit.com/reading-a-analog-in-and-control...
4 of 6 16/10/13 20:38
Last updated on 2012-07-20 at 08.33.52 PM
Related Guides
Arduino Lesson 15. DC Motor Reversing
Learn Arduino, Lesson 15. DC Motor Reversing
Arduino Lesson 14. Servo Motors
Learn Arduino, Lesson 14. Servo Motors
Connecting the Cobbler to a MCP3008 | Analog Inputs fo... http://learn.adafruit.com/reading-a-analog-in-and-control...
5 of 6 16/10/13 20:38
Adafruit Pi Cobbler Kit
Assemble your Adafruit Pi Cobbler Kit
About Adafruit
Adafruit was founded in 2005 by MIT engineer, Limor "Ladyada" Fried. Her goal was to createthe best place online for learning electronics and making the best designed products for makersof all ages and skill levels.Learn More.
The Adafruit Learning System
In 2012, after years of coding tutorials by hand, Limor put together a small team to build acustom tutorial management system from the ground up. The Adafruit Learning System allows usto make a wide range of awesome tutorials fast and efficiently. We hope these tutorials will helpyou learn something new, and inspire you to make something great!
Useful Stuff
Support Forums Adafruit Shop RSS
340 tutorials and counting
Powered by Adafruit Learning Technologies
Connecting the Cobbler to a MCP3008 | Analog Inputs fo... http://learn.adafruit.com/reading-a-analog-in-and-control...
6 of 6 16/10/13 20:38