Difference between revisions of "EBC Exercise 10a Analog In"

From eLinux.org
Jump to: navigation, search
(Initial Page)
 
m (Analog in)
Line 2: Line 2:
 
{{YoderHead}}
 
{{YoderHead}}
 
== Analog in ==
 
== Analog in ==
 +
{{EBC3.8}}This page is for the Bone (Black or White) running the 3.8 Kernel. See [[EBC_Exercise_10_Flashing_an_LED_-_xM_WhiteBone]] for the White Bone or xM running 3.2.
  
(This is based on [https://groups.google.com/forum/?fromgroups#!searchin/beagleboard/AIN/beagleboard/-ClhIXxtOds/rranYdwhS88J this].)
+
(This is based on [https://groups.google.com/forum/?fromgroups#!searchin/beagleboard/AIN/beagleboard/-ClhIXxtOds/rranYdwhS88J BeagleBone Black Analog Input].)
  
The bone has eight Analog Inputs.  Several are exposed on P9.  They are labeled '''AIN''' in table 11 above.  How many do you find?
+
The bone has eight Analog Inputs.  Several are exposed on P9.  They are labeled '''AIN''' in table 11 below.  How many do you find?
 +
 
 +
[[File:HeaderP9.jpg|800px]]
  
 
The AIN pins are sampled at 12 bits and 100k samples per second.  The input voltage is between 0 and 1.8V.  Fortunately, both voltages are available on P9.
 
The AIN pins are sampled at 12 bits and 100k samples per second.  The input voltage is between 0 and 1.8V.  Fortunately, both voltages are available on P9.
  
The photo above shows a small potentiometer wired to the bone.  One end goes to the analog ground (pin 34), the other analog 1.8V (pin 32). The wiper is attached to '''AIN5''' which is pin 36.
+
The photo below shows a small potentiometer wired to the bone.  One end goes to the analog ground (pin 34), the other analog 1.8V (pin 32). The wiper is attached to '''AIN5''' which is pin 36.
 +
 
 +
[[File:Bone gpio.JPG|300px]]
 +
[[File:BoneGPIO.png|300px]]
  
 
You interact with the analog in much like the gpio, but it appears in a different. We have to run a command before the AIN interface appears.  Just run them now, later we'll explain what you did.
 
You interact with the analog in much like the gpio, but it appears in a different. We have to run a command before the AIN interface appears.  Just run them now, later we'll explain what you did.

Revision as of 12:14, 6 June 2013

thumb‎ Embedded Linux Class by Mark A. Yoder


Analog in

3.8 Kernel

This page is for the Bone (Black or White) running the 3.8 Kernel. See EBC_Exercise_10_Flashing_an_LED_-_xM_WhiteBone for the White Bone or xM running 3.2.

(This is based on BeagleBone Black Analog Input.)

The bone has eight Analog Inputs. Several are exposed on P9. They are labeled AIN in table 11 below. How many do you find?

HeaderP9.jpg

The AIN pins are sampled at 12 bits and 100k samples per second. The input voltage is between 0 and 1.8V. Fortunately, both voltages are available on P9.

The photo below shows a small potentiometer wired to the bone. One end goes to the analog ground (pin 34), the other analog 1.8V (pin 32). The wiper is attached to AIN5 which is pin 36.

Bone gpio.JPG BoneGPIO.png

You interact with the analog in much like the gpio, but it appears in a different. We have to run a command before the AIN interface appears. Just run them now, later we'll explain what you did.

beagle$ SLOTS=/sys/devices/bone_capemgr.*/slots
beagle$ PINS=/sys/kernel/debug/pinctrl/44e10800.pinmux/pins
beagle$ echo cape-bone-iio > $SLOTS

You can now access the analog interface, but where do they appear. Try using the find command.

beagle$ find /sys -name "*AIN"
./devices/ocp.2/helper.14/AIN0
./devices/ocp.2/helper.14/AIN1
./devices/ocp.2/helper.14/AIN2
./devices/ocp.2/helper.14/AIN3
./devices/ocp.2/helper.14/AIN4
./devices/ocp.2/helper.14/AIN5
./devices/ocp.2/helper.14/AIN6
./devices/ocp.2/helper.14/AIN7

You paths may be slightly different. Now explore.

beagle$ cd /sys/devices/ocp.2/helper.14
beagle$ ls -F
AIN0  AIN2  AIN4  AIN6  driver@   power/      uevent
AIN1  AIN3  AIN5  AIN7  modalias  subsystem@

There are the various analog inputs, but watch out. This interface starts numbering at 1 and Table 11 starts at 0, so to read AIN5 you need to look at AIN6!

beagle$ cat AIN6
1185

Change the pot and rerun cat. What's the min and max value you get? Is it 12 bits?

Challenge

Rewrite the scripts from before to read an AIN pin and continuously display it's value.




thumb‎ Embedded Linux Class by Mark A. Yoder