EBC Exercise 10a Analog In

From eLinux.org
Revision as of 12:03, 28 July 2020 by Yoder (talk | contribs)
Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder

The Beagle has seven analog inputs, numbered AIN0 to AIN6. They can be read either a sample at a time (One Shot) or in blocks of samples (Continous). One shot can be used to read the setting of a potentiometer, or an analog temperature sensor. The continuous mode is for reading a microphone or some other analog signal. With the proper configuration, the continuous input can read 12 bit samples at 200k samples/second.

Here's is how to use each.

Analog in - One Shot

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.


The AIN pins are sampled at 12 bits and 8k samples per second by default. 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 place.

bone$ cd /sys/bus/iio/devices/iio:device0
bone$ ls -F
buffer/          in_voltage2_raw  in_voltage6_raw  power/
dev              in_voltage3_raw  in_voltage7_raw  scan_elements/
in_voltage0_raw  in_voltage4_raw  name             subsystem@
in_voltage1_raw  in_voltage5_raw  of_node@         uevent

There are the various analog inputs, in_voltage6_raw corresponds with AIN6

bone$ cat in_voltage6_raw

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

Analog in - Continuous

thumb‎ Embedded Linux Class by Mark A. Yoder