96 float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);
97 dac_code = (int32_t)float_code - LTC2657_offset;
100 return ((uint16_t)dac_code);
107 dac_voltage = ((float)(dac_code + LTC2657_offset)*
LTC2657_lsb);
108 return (dac_voltage);
115 *LTC2657_lsb = (voltage2 - voltage1) / ((
float) (dac_code2 - dac_code1));
116 temp_offset = voltage1/(*LTC2657_lsb) - (float)dac_code1;
117 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
118 *LTC2657_offset = (int16_t)temp_offset;
uint16_t LTC2657_voltage_to_code(float dac_voltage, float LTC2657_lsb, int16_t LTC2657_offset)
Calculate a LTC2657 DAC code given the desired output voltage and DAC address (0-3) ...
Header File for Linduino Libraries and Demo Code.
void LTC2657_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2657_lsb, int16_t *LTC2657_offset)
Calculate the LTC2657 offset and LSB voltages given two measured voltages and their corresponding cod...
int8_t i2c_write_word_data(uint8_t address, uint8_t command, uint16_t value)
Write a 16-bit word of data to register specified by "command".
static int16_t LTC2657_offset[9]
DAC offset - index 8 for "all DACs".
int8_t LTC2657_write(uint8_t i2c_address, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write a 16-bit dac_code to the LTC2657.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
static float LTC2657_lsb[9]
The LTC2657 lsb - index 8 for "all DACs".
float LTC2657_code_to_voltage(uint16_t dac_code, float LTC2657_lsb, int16_t LTC2657_offset)
Calculate the LTC2657 DAC output voltage given the DAC code, offset, and LSB value.
LTC2657: Octal I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference.