Treehopper C# API
Nau7802 Class Reference

Nuvoton NAU7802 24-bit dual-channel ADC for bridge sensors More...

Inheritance diagram for Nau7802:
AdcPeripheralPin IAdcPeripheral AdcPin IPollable

Classes

class  Nau7802Registers
 

Public Types

enum  Gains {
  x1 = 0, x4 = 1, x2 = 2, x8 = 3,
  x16 = 4, x32 = 5, x64 = 6, x128 = 7
}
 
enum  Vldoes {
  mV_4500 = 0, mV_4200 = 1, mV_3900 = 2, mV_3600 = 3,
  mV_3300 = 4, mV_3000 = 5, mV_2700 = 6, mV_2400 = 7
}
 
enum  CalMods { OffsetCalibrationInternal = 0, Reserved = 1, OffsetCalibrationSystem = 2, GainCalibrationSystem = 3 }
 
enum  ConversionRates {
  Sps_10 = 0, Sps_20 = 1, Sps_40 = 2, Sps_80 = 3,
  Sps_320 = 7
}
 

Public Member Functions

 Nau7802 (I2C i2c, DigitalIn drdy=null)
 
async Task UpdateAsync ()
 Requests a reading from the sensor and updates its data properties with the gathered values. More...
 
async Task< bool > CalibrateAsync ()
 
async Task SetChannelAsync (int channel)
 
Task MakeAnalogInAsync ()
 Make the pin an analog input. More...
 

Public Attributes

double AnalogValue => analogValueFromAdc(AdcValue)
 The analog value (from 0-1) of the ADC pin More...
 
double AnalogVoltage => analogVoltageFromAdc(AdcValue)
 The analog voltage of the pin More...
 

Protected Attributes

IAdcPeripheral parent
 

Properties

bool AutoUpdateWhenPropertyRead [get, set]
 
Gains Gain [get, set]
 
bool Cfilter [get, set]
 
ConversionRates ConversionRate [get, set]
 
double ReferenceVoltage [get, set]
 The reference voltage used for calculating analog voltage More...
 
int AdcValueChangedThreshold [get, set]
 The amount the ADC value should change before triggering an event More...
 
int AdcValue [get, set]
 The raw ADC value More...
 
double AnalogValueChangedThreshold [get, set]
 The amount that the analog value (0-1) should change before triggering an event More...
 
double AnalogVoltageChangedThreshold [get, set]
 The change in voltage required to trigger an event More...
 

Events

OnAdcValueChanged AdcValueChanged
 Fires whenever the ADC value changes by the specified threshold More...
 
OnAnalogValueChanged AnalogValueChanged
 Fires whenever the analog value changes by the specified threshold More...
 
OnAnalogVoltageChanged AnalogVoltageChanged
 Fires whenever the analog voltage changes by the specified threshold More...
 
PropertyChangedEventHandler PropertyChanged
 

Detailed Description

Nuvoton NAU7802 24-bit dual-channel ADC for bridge sensors

Member Enumeration Documentation

◆ Gains

enum Gains
strong
Enumerator
x1 
x4 
x2 
x8 
x16 
x32 
x64 
x128 

◆ Vldoes

enum Vldoes
strong
Enumerator
mV_4500 
mV_4200 
mV_3900 
mV_3600 
mV_3300 
mV_3000 
mV_2700 
mV_2400 

◆ CalMods

enum CalMods
strong
Enumerator
OffsetCalibrationInternal 
Reserved 
OffsetCalibrationSystem 
GainCalibrationSystem 

◆ ConversionRates

enum ConversionRates
strong
Enumerator
Sps_10 
Sps_20 
Sps_40 
Sps_80 
Sps_320 

Constructor & Destructor Documentation

◆ Nau7802()

Nau7802 ( I2C  i2c,
DigitalIn  drdy = null 
)

Member Function Documentation

◆ UpdateAsync()

async Task UpdateAsync ( )

Requests a reading from the sensor and updates its data properties with the gathered values.

Returns
An awaitable Task

Note that when AutoUpdateWhenPropertyRead is true (which it is, by default), this method is implicitly called when any sensor data property is read from — there's no need to call this method unless you set AutoUpdateWhenPropertyRead to false.

Unless otherwise noted, this method updates all sensor data simultaneously, which can often lead to more efficient bus usage (as well as reducing USB chattiness).

Implements IPollable.

◆ CalibrateAsync()

async Task<bool> CalibrateAsync ( )

◆ SetChannelAsync()

async Task SetChannelAsync ( int  channel)

◆ MakeAnalogInAsync()

Task MakeAnalogInAsync ( )
inherited

Make the pin an analog input.

This is unused in most implementations

Implements AdcPin.

Member Data Documentation

◆ parent

IAdcPeripheral parent
protectedinherited

◆ AnalogValue

double AnalogValue => analogValueFromAdc(AdcValue)
inherited

The analog value (from 0-1) of the ADC pin

◆ AnalogVoltage

double AnalogVoltage => analogVoltageFromAdc(AdcValue)
inherited

The analog voltage of the pin

Property Documentation

◆ AutoUpdateWhenPropertyRead

bool AutoUpdateWhenPropertyRead
getset

◆ Gain

Gains Gain
getset

◆ Cfilter

bool Cfilter
getset

◆ ConversionRate

ConversionRates ConversionRate
getset

◆ ReferenceVoltage

double ReferenceVoltage
getsetinherited

The reference voltage used for calculating analog voltage

◆ AdcValueChangedThreshold

int AdcValueChangedThreshold
getsetinherited

The amount the ADC value should change before triggering an event

◆ AdcValue

int AdcValue
getsetinherited

The raw ADC value

◆ AnalogValueChangedThreshold

double AnalogValueChangedThreshold
getsetinherited

The amount that the analog value (0-1) should change before triggering an event

◆ AnalogVoltageChangedThreshold

double AnalogVoltageChangedThreshold
getsetinherited

The change in voltage required to trigger an event

Event Documentation

◆ AdcValueChanged

OnAdcValueChanged AdcValueChanged
inherited

Fires whenever the ADC value changes by the specified threshold

◆ AnalogValueChanged

OnAnalogValueChanged AnalogValueChanged
inherited

Fires whenever the analog value changes by the specified threshold

◆ AnalogVoltageChanged

OnAnalogVoltageChanged AnalogVoltageChanged
inherited

Fires whenever the analog voltage changes by the specified threshold

◆ PropertyChanged

PropertyChangedEventHandler PropertyChanged
inherited

The documentation for this class was generated from the following file: