115 float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);
116 dac_code = (uint16_t) (float_code);
117 if (dac_code > 65535)
121 return ((uint16_t)dac_code);
130 *LTC2607_lsb = (voltage2 - voltage1) / ((
float) (dac_code2 - dac_code1));
131 temp_offset = voltage1/(*LTC2607_lsb) - dac_code1;
132 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
133 *LTC2607_offset = (int32_t)temp_offset;
static int32_t LTC2607_offset[3]
The LTC2422 offset variable.
uint16_t LTC2607_voltage_to_code(float dac_voltage, float LTC2607_lsb, int32_t LTC2607_offset)
Calculates an LTC2607 DAC code for the desired output voltage.
void LTC2607_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2607_lsb, int32_t *LTC2607_offset)
Calculates the LTC2607 offset and lsb voltage given two measured voltages and their corresponding DAC...
static float LTC2607_lsb[3]
The LTC2607 least significant bit value with 5V full-scale.
Header File for Linduino Libraries and Demo Code.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
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".
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
LTC2607: 16-Bit, Dual Rail-to-Rail DACs with I2C Interface.
int8_t LTC2607_write(uint8_t i2c_address, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Writes command, DAC address, and DAC code to the LTC2607.