Saturday, June 8, 2013

BeagleBone 1.8V Analog Logic

Intro

Unlike the Arduino which uses 5 V logic, the analog pins on the BeagleBone Black require a 1.8 V signal for the Analog to Digital converter (The device itself is 3.3V. I always have concerns doing something new with my devices with the fear of destroying them. Not being an expert in electronics, I tend to ask a lot of questions and before I make a move. The two things I wanted to get answered in the case of using the analog pins on the BBB were

1. What if a sensor does not have a datasheet or specified output voltage; is it or would it be less than 1.8 V for the BeagleBone?

2. If it is over 1.8 V, how do I use the sensor?

I'll answer both these.

Finding a sensors output voltage

This  I think was the most intimidating part of using the analog pins on the BeagleBone. I have data sheets for most my sensors but out of curiosity I did not know the best way to figure out what the output voltage would be for the maximum in put voltage. I posted the question on Google + and got a response from Jason Kridner, who is the BeagleBone aficionado from TI. He suggested I purchase the DSN Nano Oscilloscope from SeedStudio.


What advantage will this give? Almost all devices specify an input voltage on the data sheet. Using an oscilloscope will allow you to vary an input voltage to a sensor and measure the output voltage of the device. (You could do the same with a multimeter but I wanted to add an oscilloscope to my toolbox). 

Using Analog on the BeagleBone

Hipstercircuits had a great write up on how to enable the driver for the analog pins. Follow this link. The BeagleBone Black has specific pins that are analog. They are physical pins 33,35,36,37,38,39,40 and 41 is analog ground. I used my TMP-36 temperature sensor for my first analog project because it outputs 1.8 V. This is the maximum allowable for the Analog to Digital converter on the BBB. Here is a shot of how it was hooked up. Red is 3.3V, Black is ground and Blue goes to one of the analog pins. A cheat sheet can be found below for the physical pins and I labeled the analog pins.



The BeagleBone will give the measured values in mV so the values you will read from the low hundreds to about 1800. To acccess a specific pin you can execute the following command:

TMP-36 Sensor Wiring
cat /sys/devices/ocp.2/helper.14/AIN1

This will access AIN1 which is physical pin 40. Just as I did in my Blink.py example I wrote a python script to read the analog value and convert it to a temperature based on the information Adafruit provides for with the data sheet for the sensor.

The python code can be found at this link TMP-36.py

On my particular device the path is "helper.14" but I have seen others with a different # on their directory. If 14 does not work for you just type "helper." then tab and it will fill in auto complete.

I'll answer the question of "If it is over 1.8 V, how do I use the sensor?" in my next post.

2 comments:

  1. Any idea how much max current goes into the analog inputs?

    I read 2 micro amps, but that's hard to believe.

    ReplyDelete
    Replies
    1. I have read it is 2 uAmps as well and also find that hard to believe.

      Delete