Loading...
Searching...
No Matches
MAX11635 Class Reference

Driver for the on-board MAX11635 12-bit ADC (U5). More...

Public Member Functions

 averaging (self)
 Conversions the chip averages for each result: 1, 4, 8, 16 or 32.
 set_averaging (self, samples)
 Sets how many conversions the chip averages for each result.
 read (self, channel)
 Runs one conversion (averaged if set with set_averaging()).
 scan (self, last_channel=3)
 Converts channels 0 to last_channel in one scan, a few us apart.
 read_differential (self, pair=0, bipolar=True)
 True differential conversion, both inputs sampled at the same instant.

Static Public Attributes

int CHANNELS = 4
 Number of input channels (AIN0-AIN3).
int VBUS_CHANNEL = 3
 Channel that measures VBUS (through the 100 kOhm / 10.2 kOhm divider).

Detailed Description

Driver for the on-board MAX11635 12-bit ADC (U5).

Channels 0-2 are A3-A5; channel 3 measures VBUS through a divider. Most programs use analog_read() and the other analog functions instead; use external_adc() to get the board's instance rather than making another.

SPI bus configuration: SPI0 at 4 MHz, mode 0 (SCK GPIO22, MOSI GPIO23, MISO GPIO20, CS GPIO21), CNVST GPIO18, EOC GPIO19.

External 2.048 V reference, conversions started by CNVST (clock mode 00). Making the object resets the chip.

Member Function Documentation

◆ set_averaging()

set_averaging ( self,
samples )

Sets how many conversions the chip averages for each result.

Parameters
samples1 (off), 4, 8, 16 or 32; other values use the next lower one (values below 1 use 1).
Returns
The setting used.

◆ read()

read ( self,
channel )

Runs one conversion (averaged if set with set_averaging()).

Parameters
channelInput 0-3 (0-2 are A3-A5, 3 is VBUS).
Returns
0-4095 (0 V to 2.048 V).
Exceptions
ValueErrorThe channel is not 0-3.
OSErrorThe chip did not respond.

◆ scan()

scan ( self,
last_channel = 3 )

Converts channels 0 to last_channel in one scan, a few us apart.

Parameters
last_channelHighest channel, 0-3.
Returns
A list of last_channel + 1 codes, 0-4095.
Exceptions
ValueErrorlast_channel is not 0-3.
OSErrorThe chip did not respond.

◆ read_differential()

read_differential ( self,
pair = 0,
bipolar = True )

True differential conversion, both inputs sampled at the same instant.

Pair 0 is AIN0 - AIN1 (A3 - A4); pair 1 is AIN2 - AIN3 (A5 - VBUS monitor). The pair is set back to single-ended afterwards.

Parameters
pair0 or 1.
bipolarTrue: -2048 to 2047 (-1.024 V to +1.024 V, 0.5 mV steps). False: 0 to 4095 (0 V to 2.048 V; a negative difference reads 0).
Returns
The code.
Exceptions
ValueErrorThe pair is not 0 or 1.
OSErrorThe chip did not respond.

The documentation for this class was generated from the following file:
  • phyduino.py