|
lolxnano
Code to control the LoLX SiPM biasing board from the connected nanoPi
|
Class interfacing the TI ADS1248 ADC chip. More...
#include <ads1248.h>
Public Member Functions | |
| Ads1248 (NanoPi &np, int cs) | |
| Constructor. | |
| void | Reset () |
| Reset registers to default values. | |
| void | StopC () |
| Turn off continuous data readout. | |
| uint8_t | ReadReg (uint8_t reg) |
| Read register. | |
| void | WriteReg (uint8_t reg, uint8_t data) |
| Write register. | |
| int32_t | ReadData () |
| Read data from ADC. | |
| bool | SetCh (unsigned short ch0, unsigned short ch1) |
| Select which inputs to measure between. | |
| bool | SetGainRate (int gain, int rate) |
| Set gain (0..7) and rate (0..9) settings, see manual. | |
| std::pair< unsigned short, unsigned short > | GetGainRate () |
| Return (gain, rate) in real units (rate in Hz) | |
| double | GetVal (double data) |
| Convert readout into voltage using set constant. | |
| void | SetCGain (double g) |
| Set conversion gain (mutliplied in GetVal()) | |
| void | SetResist (double r) |
| Convenience function to set conversion gain via load resistor to measure current. | |
| void | SetVref (double v) |
| Set reference voltage applied to ADC. | |
| double | GetTemp (unsigned short n=5) |
| Read out chip temperature. | |
Class interfacing the TI ADS1248 ADC chip.
This contains everything needed for the SPI communication with an ADS1248 ADC chip,
|
inline |
Constructor.
| np | An instance of a NanoPi object, needed for the actual hardware communication |
| cs | SPI channel select addressing the chip in question |
| double Ads1248::GetTemp | ( | unsigned short | n = 5 | ) |
Read out chip temperature.
| n | average temperature over n read cycles (default 5) |
|
inline |
Convert readout into voltage using set constant.
V = 2*Vref/2^24 * cgain/gain
Vref: external reference voltage
gain: ADC gain
cgain: conversion "gain", e.g. amplification after ADC, or conversion to current via load resistor
| int32_t Ads1248::ReadData | ( | ) |
Read data from ADC.
Performs READ communication with the ADC and converts the result into a 32-bit integer.
| bool Ads1248::SetGainRate | ( | int | gain, |
| int | rate ) |
Set gain (0..7) and rate (0..9) settings, see manual.
Gain settings:
gain = 2^setting
| Setting | Gain |
|---|---|
| 0 | 1 |
| 1 | 2 |
| 2 | 4 |
| 3 | 8 |
| 4 | 16 |
| 5 | 32 |
| 6 | 64 |
| 7 | 128 |
Rate settings:
rate = 5Hz * 2^setting up to setting 7, then different
| Setting | Rate (Hz) |
|---|---|
| 0 | 5 |
| 1 | 10 |
| 2 | 20 |
| 3 | 40 |
| 4 | 80 |
| 5 | 160 |
| 6 | 320 |
| 7 | 640 |
| 8 | 1000 |
| 9+ | 2000 |