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

From eLinux.org
Jump to: navigation, search
m (Analog in)
Line 10: Line 10:
 
[[File:HeaderP9.jpg|800px]]
 
[[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 8k 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.
 
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.
Line 17: Line 17:
 
[[File:BoneGPIO.png|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 place.  
Note: On the debian 8.5 image, you must be logged in as root in order to use the '>' modifier. use 'su root' to do this. (otherwise you will get a permissions error)
 
  
  beagle$ '''cd /sys/devices/platform/bone_capemgr'''
+
  bone$ '''cd /sys/bus/iio/devices/iio:device0'''
beagle$ '''echo BB-ADC > slots'''
+
  bone$ '''ls -F'''
 
+
  buffer/          in_voltage2_raw in_voltage6_raw power/
You can now access the analog interface, but where do they appear.  Try using the '''find''' command.
+
  dev             in_voltage3_raw  in_voltage7_raw  scan_elements/
 
+
  in_voltage0_raw in_voltage4_raw name            subsystem@
beagle$ '''find /sys -name "in_voltage*_raw"'''
+
  in_voltage1_raw in_voltage5_raw of_node@        uevent
 
 
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage0_raw
 
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage1_raw
 
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage2_raw
 
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage3_raw
 
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage4_raw
 
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage5_raw
 
/sys/devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0/in_voltage6_raw
 
 
 
 
 
Ian's Notes: If find /sys -name "*AIN" fails, try find /sys -name "*AIN*"
 
 
 
You paths may be slightly different. Now explore.
 
 
 
beagle$ '''cd /sys/bus/iio/devices/iio:device0'''
 
  beagle$ '''ls -F'''
 
 
 
  buffer in_voltage1_raw in_voltage4_raw name    scan_elements
 
  dev in_voltage2_raw in_voltage5_raw of_node subsystem
 
  in_voltage0_raw in_voltage3_raw in_voltage6_raw  power    uevent
 
  
 
There are the various analog inputs, in_voltage6_raw corresponds with AIN6
 
There are the various analog inputs, in_voltage6_raw corresponds with AIN6
  
  beagle$ '''cat in_voltage6_raw'''
+
  bone$ '''cat in_voltage6_raw'''
 
  1185
 
  1185
  
 
Change the pot and rerun '''cat'''.  What's the min and max value you get?  Is it 12 bits?
 
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.
 
  
 
{{YoderFoot}}
 
{{YoderFoot}}

Revision as of 13:04, 23 July 2020

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 8k 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 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
1185

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




thumb‎ Embedded Linux Class by Mark A. Yoder