element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum 11 year old's blog and adc question
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 6 replies
  • Subscribers 665 subscribers
  • Views 561 views
  • Users 0 members are here
  • raspberry
  • python
  • digital
  • to
  • pi
  • converter
  • raspberry_pi
  • rpi
  • analog
Related

11 year old's blog and adc question

Former Member
Former Member over 12 years ago

I'm an 11-year old girl who has been using the RPi for about 5 months.  I've used Python in VIM, IDLE, Midory, OpenELEC, Scratch, and GPIO so far.  Check out my adventures on my blog at http://raspberrypikid.wordpress.com and some of my projects in Scratch are here: http://scratch.mit.edu/krystal92586 (I think the website is down until May 9th.  I can't wait for Scratch 2.0!)

 

I bought an analog to digital converter from Adafruit, but the instructions are way too hard for me (bit banging?).  Anybody have a set of simple instructions?  I'd just like to use sound, light, temperature probes with my RPi.

 

Krystal

  • Sign in to reply
  • Cancel
  • Nate1616
    Nate1616 over 12 years ago

    Hey Krystal

    Its very cool to see someone your age getting involved in electronics and its even better that your blogging about it.  Keep up the good work.image  As for a set of simple istructions i can not think of any off the top of my head.  Myabe someone else will know of some.

    Nate

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago

    Hey Krystal,

     

    Kudos to you! I think what you're doing is really cool.

     

    Interfacing with an analog to digital converter is not really much harder than what you have already been doing, so let's see if we can get you going.

     

    First of all, let's start by figuring out which device you bought. They all work pretty much the same way, but there are some differences. Just post a link to the product you bought.

     

    Before trying to connect light or temperature sensors, I'd recommend connecting a simple potentiometer. That way, you can get used to the ideas behind analog to digital conversion without having to think about how to work with a particular kind of sensor.

     

    So let's start with the model of AtoD you bought and take it from there.

     

    best,

     

    Derek

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • fustini
    fustini over 12 years ago

    Hi - great to hear about all you've been doing.  Adafruit has lovely tutorials for all of their products.  It should be in here:

     

    http://learn.adafruit.com/category/raspberry-pi

     

    Maybe this one?

     

    http://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi

     

    It is for the Microchip MCP3008 ADC chip: http://www.adafruit.com/products/856

     

    Btw, I highly recommend Adafruit's WebIDE.  It makes using Python to interface with hardware modules much simpler:

    http://learn.adafruit.com/webide/overview

     

    Cheers,

    Drew

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    Thanks everyone.  It is the mcp3008 found here: http://www.adafruit.com/products/856

    I love adafruit's website, but that's where I saw the instructions that were way too hard for me.  It's the same instructions that Drew linked to.  For example, I have no idea what any of this means, "Advanced users may note that the Raspberry Pi does have a hardware SPI interface (the cobbler pins are labeled MISO/MOSI/SCLK/CE0/CE1). The hardware SPI interface is super fast but not included in all distributions. For that reason we are using a bit banged SPI implementation so the SPI pins can be any of the raspberry pi's GPIOs (assuming you update the script)."

     

    Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mcb1
    mcb1 over 12 years ago in reply to Former Member

    Krystal

    Some of the instructions are hard for me as well, but at your age learning is a lot easier.

     

    SPI is used on the PiFace Digital.

    There is some information here that may help.

    http://www.farnell.com/datasheets/1686131.pdf

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 12 years ago in reply to Former Member

    That's great. Ok, let's move on by understanding these (not so) scary techwords :-)

     

    First of all, SPI. It stands for 'Serial Peripheral Interconnect'. The 'Peripheral' in this case is your ADC chip. The 'Serial' part tells you that your chip is going to communicate with your Pi by wiggling some pins between high and low voltages. This is not scary or even high tech, people have been doing this since the early days of the railroad. Google: 'Morse Code' and 'Telegraph' to find out more. In those days, people did the wiggling, but your ADC and your Pi are going to be doing all the wiggling for you.

     

    The pins which are going to wiggle are called MOSI and MISO. MOSI stands for 'Master Out, Slave In' and MISO stands for ... you guessed it, 'Master in, Slave Out'. Your Pi is the 'Master' and your new ADC chip is the 'Slave'. So to send commands to your ADC, you'll be sending information as high and low voltages from the Pi across the MOSI pin and to receive analog voltage readings back, your Pi will be listening to the high and low voltages being sent by the ADC chip on the MISO pin.

     

    Now just a wee bit more info: SCLK is another wiggling pin which is controlled by your Pi. It tells the ADC when to listen for a value on MOSI and when to put a high or a low voltage on the MISO pin. SCLK only wiggles when the Pi wants to send and/or receive information. Remember. your Pi is the Master, so it gets to decide when it wants to send or receive.

     

    Now for some good news, you can connect more than one ADC (or any other SPI chip) to the MISO and MOSI signals from your Pi. This allows you to do more cool stuff than just read analog voltages. However, to do this, the Pi needs to be able to tell which chip it wants to communicate with. That is where CE0 and CE1 come in. They stand for 'Chip Enable zero' and 'Chip Enable one'. In your case, you'll want to use CE0.

     

    Finally, let's deal with 'bit banging'. The Pi can communicate across the SPI interface automatically using its hardware, or you can wiggle the pins up and down yourself using a program to do it. When you use a program, it's called 'bit banging', that's all there is to it, not scary either.

     

    So, to start working with your ADC you connect Pi SCLK to the ADC CLK pin, MOSI to DIN (Data In), MISO to DOUT (Data Out) and CE0 to CE. You'll also need to connect power and ground signals and of course you'll want to connect up an analog voltage to measure. All these connections are covered in the Adafruit tutorial which you probably already found here: http://learn.adafruit.com/send-raspberry-pi-data-to-cosm.

     

    This tutorial shows a temperature sensor, you may want to start instead with a potentiometer if you have one. If so, you'll connect one outside leg of the potentiometer to 3.3v and the other outside leg to GND (it doesn't matter to start with which leg is which). You connect the center leg to pin 1 of the ADC.

     

    Setting up COSM as described in the AdaFruit tutorial is also a bit involved for a first experiment.

     

    Instead, there is some 'bit banging' python code here:

     

    https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/blob/master/Adafruit_MCP3008/mcp3008.py

     

    I think this is going to be simpler for you to start with. You can always hook up to COSM and other cool stuff later.

     

    Phew! None of this is scary, but I realize it is quite a lot to take in. I hope I didn't put you off with all the above information. Do please let us know how you get on, and of course if you have any follow up questions, we'll be happy to try and answer them. We'll _definitely_ get you going and once you do, I'm sure your imagination will go on overdrive.

     

    Good luck!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube