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). | |
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.
| set_averaging | ( | self, | |
| samples ) |
Sets how many conversions the chip averages for each result.
| samples | 1 (off), 4, 8, 16 or 32; other values use the next lower one (values below 1 use 1). |
| read | ( | self, | |
| channel ) |
Runs one conversion (averaged if set with set_averaging()).
| channel | Input 0-3 (0-2 are A3-A5, 3 is VBUS). |
| ValueError | The channel is not 0-3. |
| OSError | The chip did not respond. |
| scan | ( | self, | |
| last_channel = 3 ) |
Converts channels 0 to last_channel in one scan, a few us apart.
| last_channel | Highest channel, 0-3. |
| ValueError | last_channel is not 0-3. |
| OSError | The chip did not respond. |
| 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.
| pair | 0 or 1. |
| bipolar | True: -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). |
| ValueError | The pair is not 0 or 1. |
| OSError | The chip did not respond. |