-
Notifications
You must be signed in to change notification settings - Fork 87
Analog to digital converter
Alexander Hiam edited this page Jan 22, 2014
·
3 revisions
The BeagleBone's processor has a built-in 8-channel 12-bit ADC module. Seven of the input channels are broken out on the P9 header, all of which can be used with PyBBIO. The ADC approximates the voltage present on any of the input pins within its allowable range of 0-1.8v, and gives a corresponding value in the range of 0-212, or 0-4069. This means it has a resolution of 1.8v / 212, or 0.000439 volts/step.
Applying voltages greater than 1.8v to the ADC pins can cause permanent damage to your BeagleBone!
###Example programs:
PyBBIO/examples/analog_test.py
PyBBIO/examples/knock.py
###Functions:
#####analogRead(analog_pin)
Takes a reading of the given analog pin and returns the 12-bit value.
Note: currently on the BeagleBone Black and kernels >= 3.8, this instead returns the voltage in millivolts on the given pin.
#####inVolts(adc_value, bits=12, vRef=1.8)
Converts the given ADC value to a voltage, according to the given number of bits and reference voltage, and returns it. The default values match the built-in ADC.
###Available ADC pins: Pins listed in form:
Location - function
#####Header P9:
P9.33 - AIN4
P9.35 - AIN6
P9.36 - AIN5
P9.37 - AIN2
P9.38 - AIN3
P9.39 - AIN0