4#define DAC_RB_ENABLE 0b1001
5#define DAC_WRITESET 0b0011
6#define DAC_POWUPDN 0b0100
9#define DAC_SLOPE_QP -1257.86
10#define DAC_OFFSET_QP 116289.0
11#define DAC_SLOPE_HV -641.931
12#define DAC_OFFSET_HV 50730.5
20#define DAC_VREF_HV 2.5
21#define DAC_SLOPE34_HV double(1<<16)/2.5
24#define DAC_ENHV_EN 0xfefe
48 std::cout <<
"SPI/GPIO not yet initialized!" << std::endl;
50 std::cout <<
"AD56x6::cselect = " << cselect <<
", nanoPi = " << nanoPi << std::endl;
53 unsigned char *
AssembleWord(uint8_t cmd, uint8_t chan, uint16_t *data = NULL);
54 bool Set(
unsigned short chan, uint16_t setting,
bool confirm =
true);
55 virtual uint16_t
GetSetting(
double v,
unsigned short chan = 0) = 0;
56 virtual double GetVoltage(uint16_t s,
unsigned short chan = 0) = 0;
66 bool RampVoltage(
unsigned short chan, uint16_t vset = -1,
unsigned int steps = 16,
unsigned int tdelay = 500);
82 virtual uint8_t
EncChan(uint8_t chan) {
return 0xF & chan; };
105 uint16_t
GetSetting(
double v,
unsigned short chan = 0);
107 double GetVoltage(uint16_t s,
unsigned short chan = 0);
114 double vref = DAC_VREF;
137 bool SetInternalRef(
bool on =
true);
138 uint16_t
GetSetting(
double v,
unsigned short chan);
139 double GetVoltage(uint16_t s,
unsigned short chan);
140 void SetCalib(std::vector<double> sl, std::vector<double> offs)
142 slope = sl; offset = offs;
153 bool DisableHV(){
return EnableHV(
false); };
157 uint8_t EncChan(uint8_t chan)
159 return 0xF & (1 << chan);
161 std::vector<double> slope = { DAC_SLOPE_QP, DAC_SLOPE_HV, DAC_SLOPE34_HV, DAC_SLOPE34_HV };
162 std::vector<double> offset = { DAC_OFFSET_QP, DAC_OFFSET_HV, 0., 0. };
uint16_t GetSetting(double v, unsigned short chan=0)
Calibration specific to the bias tuning DACs.
Definition ad56x6.cc:92
void SetVref(double v)
Method to change the DAC reference voltage value for calibration calculations.
Definition ad56x6.h:109
double GetVoltage(uint16_t s, unsigned short chan=0)
Calibration specific to the bias tuning DACs.
Definition ad56x6.cc:98
uint16_t GetSetting(double v, unsigned short chan)
Calibration specific to the HV DAC.
Definition ad56x6.cc:102
bool EnableHV(bool on=true)
Turn HV amplifier on/off.
Definition ad56x6.cc:127
double GetVoltage(uint16_t s, unsigned short chan)
Calibration specific to the HV DAC.
Definition ad56x6.cc:112
void SetCalib(std::vector< double > sl, std::vector< double > offs)
Definition ad56x6.h:140
bool IsHVEnabled()
Check status of output 3, return whether it is HIGH (HV enabled) or LOW (HV disabled)
Definition ad56x6.cc:120
Parent class containing methods common to AD5666, AD5676, and AD5686 DAC chips.
Definition ad56x6.h:38
virtual uint8_t EncChan(uint8_t chan)
Format channel number for use in SPI word (3-bit number)
Definition ad56x6.h:82
const uint16_t vfull
Full scale output.
Definition ad56x6.h:76
virtual uint16_t GetSetting(double v, unsigned short chan=0)=0
Translates analog voltage to DAC setting, requires calibration.
virtual double GetVoltage(uint16_t s, unsigned short chan=0)=0
Translates DAC setting to analog voltage, requires calibration.
void Readback(short ch=-1)
Read back DAC settings and write them to vector readback.
Definition ad56x6.cc:24
void PowerOn()
Send POWER_UP command to DAC.
Definition ad56x6.h:68
unsigned char * AssembleWord(uint8_t cmd, uint8_t chan, uint16_t *data=NULL)
Assembles the SPI word from command, channel, and data.
Definition ad56x6.cc:8
uint16_t GetData()
Extract 16 bit setting from readback word.
Definition ad56x6.cc:19
const uint8_t nbytes
Size of data word in bytes.
Definition ad56x6.h:77
AD56x6(NanoPi &np, int cs)
Constructor.
Definition ad56x6.h:46
std::vector< uint16_t > readback
Read back DAC settings after Readback() was called.
Definition ad56x6.h:78
bool RampVoltage(unsigned short chan, uint16_t vset=-1, unsigned int steps=16, unsigned int tdelay=500)
Test method to ramp through voltage settings.
Definition ad56x6.cc:67
bool Set(unsigned short chan, uint16_t setting, bool confirm=true)
Sets the selected DAC channel to a value, confirms with readback.
Definition ad56x6.cc:43
Class to control GPIO and SPI communication from a nanoPi Neo2.
Definition nanopi.h:50
bool HasGPIO()
Check whether GPIO was correctly initialized.
Definition nanopi.h:60
bool HasSPI()
Check whether SPI was correctly initialized.
Definition nanopi.h:58