101 float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);
102 dac_code = (int32_t)float_code - LTC2637_offset;
105 return ((uint16_t)dac_code);
112 dac_voltage = ((float)(dac_code + LTC2637_offset)*
LTC2637_lsb);
113 return (dac_voltage);
120 *LTC2637_lsb = (voltage2 - voltage1) / ((
float) (dac_code2 - dac_code1));
121 temp_offset = voltage1/(*LTC2637_lsb) - (float)dac_code1;
122 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
123 *LTC2637_offset = (int16_t)temp_offset;
static int16_t LTC2637_offset[9]
DAC offset - index 8 for "all DACs".
static float LTC2637_lsb[9]
The LTC2637 lsb - index 8 for "all DACs".
LTC2637: Octal 12-/10-/8-Bit I2C VOUT DACs with 10ppm/°C Reference.
float LTC2637_code_to_voltage(uint16_t dac_code, float LTC2637_lsb, int16_t LTC2637_offset)
Calculate the LTC2637 DAC output voltage given the DAC code, offset, and LSB value.
void LTC2637_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2637_lsb, int16_t *LTC2637_offset)
Calculate the LTC2637 offset and LSB voltages given two measured voltages and their corresponding cod...
Header File for Linduino Libraries and Demo Code.
int8_t LTC2637_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 LTC2637.
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".
uint16_t LTC2637_voltage_to_code(float dac_voltage, float LTC2637_lsb, int16_t LTC2637_offset)
Calculate a LTC2637 DAC code given the desired output voltage and DAC address (0-3) ...
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.