The A2DPortFS Class


The A2DPortFS Class

The A2DPort class reads from the one of the seven A2D bus On Chip Peripheral (OCP) devices integrated into the Beaglebone Black CPU via the IIO device driver access method. At this time there is no BBBCSIO class of similar functionality which uses the Memory Mapped access method.


Source Code

The source code for this class is available online for download and also in browseable form.


Example Code

Example code which demonstrates the use of this class can be found on the A2D Port Example page.



public class A2DPortFS : PortFS

Provides Analog to Digital (A2D) port functionality for a BeagleBone Black (SYSFS/IIO Version).


Public Constructors

public A2DPortFS(A2DPortEnum a2dPortIn) : base(GpioEnum.GPIO_NONE)


a2dPortIn - The A2D port to access.


Public Methods

public override void ClosePort()

Closes the port.


public void Dispose()

Implements IDisposable. Should be called after the class is closed to release resources.


public override PortDirectionEnum PortDirection()

Gets the PortDirection

A PortDirectionEnum value. This value is always PortDirectionEnum.PORTDIR_INPUT.


public uint Read()

Reads the current value in from an A2D Device.

Tests indicate that the maximum possible speed here is about 1000 reads/second

Be aware that the max and min value you get here can be scaled by the Device Tree setting in use. The min and max is always representative of 0V and 1.8V respectively. If you used the BB-ADC overlay then 0V-1.8V is represented by the values 0-4095. If you used the cape-bone-iio overlay then 0V-1.8V is represented by the values 0-1799. In other words, the scaling of the output is not necessarily fixed and it is up to you to know what voltage the output numbers represent.

As an additional note, in the first Device Tree Overlay (BB-ADC) the returned values 0-1799 represent simple millivolts. So if you see a value of 1234 you know there is 1.234V on the input. However the A2D inside the BBB is 12 bits so if you wish to achieve maximum resolution you can use the range 0-4095 (thus you have over double the resolution of the 0-1799) range. A value 4095 still means 1.8V though - you just are measuring the voltage with a finer granularity.


Public Properties

public A2DPortEnum A2DPort { get; }

Gets the A2D Port. There is no Set accessor this is set in the constructor

The working A2DPortEnum.