Table of Contents

Class AdcController

Namespace
nanoFramework.GiantGecko.Adc
Assembly
nanoFramework.GiantGecko.Adc.dll

Represents an AdcController on the system.

public class AdcController : AdcControllerBase
Inheritance
AdcController
Inherited Members
Extension Methods

Remarks

This class implements specifics of the Silabs Giant Gecko EFM32 ADC. It's meant to be used instead of the standard System.Adc.

Constructors

AdcController()

Initializes a new instance of the AdcController class. A default AdcConfiguration is used.

public AdcController()

Exceptions

InvalidOperationException

If the AdcController has already been instantiated.

AdcController(AdcConfiguration)

Initializes a new instance of the AdcController class.

public AdcController(AdcConfiguration acdInitialization)

Parameters

acdInitialization AdcConfiguration

Initialization configuration for the AdcController.

Exceptions

InvalidOperationException

If the AdcController has already been instantiated.

Properties

AcdConfiguration

Initialization configuration for AdcController.

public AdcConfiguration AcdConfiguration { get; }

Property Value

AdcConfiguration

ChannelCount

The number of channels available on the AdcController.

public override int ChannelCount { get; }

Property Value

int

Number of channels.

IsContinuousSamplingRunning

Returns true if the ADC is currently running in scan mode, started via StartContinuousSampling(int[]) or StartAveragedContinuousSampling(int[], int). false otherwise.

public bool IsContinuousSamplingRunning { get; }

Property Value

bool

LastContinuousSamples

Gets an array with the last samples from an ongoing scan operation.

public int[] LastContinuousSamples { get; }

Property Value

int[]

Remarks

The values are either the last sample value (if started with StartContinuousSampling(int[])) or the average of the last samples count (if the averaged continuous scan was started with StartAveragedContinuousSampling(int[], int)). The array is indexed by the position of the channel in the array passed to StartContinuousSampling(int[]) or StartAveragedContinuousSampling(int[], int). For example, if StartContinuousSampling(int[])([channel_idda, channel_idd3_3]) was called, then [0] would have value for channel_idda and LastContinuousSamples[1] would have value for channel_idd3_3. The last continuous sample for a channel may also be retrieved from AdcChannel.LastContinuousValue.

Please see remarks on StartContinuousSampling(int[]) and StartAveragedContinuousSampling(int[], int) for more information on continuous sampling.

Exceptions

InvalidOperationException

The ADC is not performing a scan operation. This has to be started with a call to StartContinuousSampling(int[]) or StartAveragedContinuousSampling(int[], int).

SupportedResolutionsInBits

Gets the resolution(s) of the controller as number of bits it has. For example, if we have a 10-bit ADC, that means it can detect 1024 (2^10) discrete levels.

public override SampleResolution[] SupportedResolutionsInBits { get; }

Property Value

SampleResolution[]

Array with the resolution(s) that the ADC has support for.

Methods

OpenChannel(int)

Opens a connection to the specified ADC channel.

public override AdcChannel OpenChannel(int channelNumber)

Parameters

channelNumber int

The channel to connect to.

Returns

AdcChannel

The ADC channel.

OpenChannel(int, AdcChannelConfiguration)

Opens a connection to the specified ADC channel with the specified configurations.

public override AdcChannel OpenChannel(int channelNumber, AdcChannelConfiguration configuration)

Parameters

channelNumber int

The channel to connect to.

configuration AdcChannelConfiguration

Initial configuration for ADC channel.

Returns

AdcChannel

The ADC channel.

StartAveragedContinuousSampling(int[], int)

Starts continuous sampling and average the digital representation of count analog values read from the ADC.

public void StartAveragedContinuousSampling(int[] channels, int count)

Parameters

channels int[]

Array of channels to scan performing continuous sampling.

count int

Number of samples to take for averaging.

Remarks

In this mode, the last count samples are averaged and made available in LastScanConversion[0].

Exceptions

InvalidOperationException
ArgumentException

If the specified channel index does not exist.

StartAveragedContinuousSampling(int[], AdcChannelConfiguration, int)

Starts continuous sampling and average the digital representation of count analog values read from the ADC.

public void StartAveragedContinuousSampling(int[] channels, AdcChannelConfiguration configuration, int count)

Parameters

channels int[]

Array of channels to scan performing continuous sampling.

configuration AdcChannelConfiguration

Initial configuration for the various ADC channels.

count int

Number of samples to take for averaging.

Remarks

In this mode, the last count samples are averaged and made available in LastScanConversion[0].

Exceptions

InvalidOperationException
ArgumentException

If the specified channel index does not exist.

StartContinuousSampling(int[])

Starts continuous sampling on the specified channels using the default AdcChannelConfiguration.

public void StartContinuousSampling(int[] channels)

Parameters

channels int[]

Array of channels indexes to scan performing continuous sampling.

Exceptions

InvalidOperationException

If a previous continuous sampling operation has been started previously without being stopped.

ArgumentException

If the specified channel index does not exist.

StartContinuousSampling(int[], AdcChannelConfiguration)

Starts continuous sampling on the specified channels using the specified AdcChannelConfiguration.

public void StartContinuousSampling(int[] channels, AdcChannelConfiguration configuration)

Parameters

channels int[]

Array of channels indexes to scan performing continuous sampling.

configuration AdcChannelConfiguration

Initial configuration for the various ADC channels.

Exceptions

InvalidOperationException

If a previous continuous sampling operation has been started previously without being stopped.

ArgumentException

If the specified channel index does not exist.

StopContinuousSampling()

Stops an ongoing continuous sampling operation.

public void StopContinuousSampling()

Exceptions

InvalidOperationException

If there is no ongoing continuous sampling operation.