79 void LTC2656_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
82 uint8_t data_array[3], rx_array[3];
87 data_array[2] = dac_command | dac_address;
88 data_array[1] = data.
LT_byte[1];
100 float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);
101 dac_code =(int32_t)float_code - LTC2656_offset;
104 return ((uint16_t)dac_code);
111 dac_voltage = ((float)(dac_code + LTC2656_offset)*
LTC2656_lsb);
112 return (dac_voltage);
119 *LTC2656_lsb = (voltage2 - voltage1) / ((
float) (dac_code2 - dac_code1));
120 temp_offset = voltage1/(*LTC2656_lsb) - (float)dac_code1;
121 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
122 *LTC2656_offset = (int16_t)temp_offset;
static float LTC2656_lsb[9]
The LTC2656 lsb - index 8 for "all DACs".
Header File for Linduino Libraries and Demo Code.
float LTC2656_code_to_voltage(uint16_t dac_code, float LTC2656_lsb, int16_t LTC2656_offset)
Calculate the LTC2656 DAC output voltage given the DAC code, offset, and LSB value.
void LTC2656_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2656_lsb, int16_t *LTC2656_offset)
Calculate the LTC2656 offset and LSB voltage given two measured voltages and their corresponding code...
union LT_union_int32_4bytes data
void LTC2656_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2656.
static int16_t LTC2656_offset[9]
DAC offset - index 8 for "all DACs".
uint16_t LT_uint16
16-bit unsigned integer to be converted to two bytes
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
This union splits one int16_t (16-bit signed integer) or uint16_t (16-bit unsigned integer) into two ...
void spi_transfer_block(uint8_t cs_pin, uint8_t *tx, uint8_t *rx, uint8_t length)
Reads and sends a byte array.
uint8_t LT_byte[2]
2 bytes (unsigned 8-bit integers) to be converted to a 16-bit signed or unsigned integer ...
uint16_t LTC2656_voltage_to_code(float dac_voltage, float LTC2656_lsb, int16_t LTC2656_offset)
Calculate a LTC2656 DAC code given the desired output voltage and DAC address (0-7) ...
LTC2656: Octal SPI 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference.