Skip to content

Class: ADCDifferentialPi

Brian Dorey edited this page Jul 1, 2017 · 1 revision

ADCDifferentialPi

This class contains methods for use with the ADC Differential Pi from https://www.abelectronics.co.uk/p/65/ADC-Differential-Pi-Raspberry-Pi-Analogue-to-Digital-converter

Methods:

Connect() 

Connect to the I2C device
Parameters: none
Returns: null

IsConnected() 

Check if the device is connected Parameters: none
Returns: boolean

Dispose() 

Dispose of the active I2C device
Parameters: none
Returns: null

ReadVoltage(byte channel)

Read the voltage from the selected channel
Parameters: channel as int - 1 to 8
Returns: number as double between 0 and 5.0

ReadRaw(byte channel)

Read the raw int value from the selected channel
Parameters: channel as int - 1 to 8
Returns: raw integer value from ADC buffer

SetPGA(byte gain)

Set the gain of the PDA on the chip
Parameters: gain as int - 1, 2, 4, 8
Returns: null

SetBitRate(byte rate)

Set the sample bit rate of the adc
Parameters: rate as int - 12, 14, 16, 18
Returns: null
12 = 12 bit (240SPS max)
14 = 14 bit (60SPS max)
16 = 16 bit (15SPS max)
18 = 18 bit (3.75SPS max)

SetConversionMode(bool mode)

Set the conversion mode for the adc
Parameters: mode as boolean - false = One-shot conversion, true = Continuous conversion
Returns: null

Usage

To use the Delta Sigma Pi library in your code you must first import the library dll:

using ABElectronics_Win10IOT_Libraries;

Next you must initialise the adc class:

ABElectronics_Win10IOT_Libraries.DeltaSigmaPi adc = new DeltaSigmaPi(0x68, 0x69);

The arguments are the two I2C addresses of the ADC chips. The values shown are the default addresses of the Delta Sigma Pi board.

Next we need to connect to the device and wait for the connection before setting the bit rate and gain. The sample rate can be 12, 14, 16 or 18

adc.Connect();

while (!adc.IsConnected)
{
}
adc.SetBitRate(18);
adc.SetPGA(1);

You can now read the voltage from channel 1 with:

double readvalue = 0;

readvalue = adc.ReadVoltage(1);
Clone this wiki locally