84 void LTC2636_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
86 uint8_t data_array[3], rx_array[3];
91 data_array[2] = dac_command | dac_address;
92 data_array[1] = data.
LT_byte[1];
93 data_array[0] = data.
LT_byte[0];
104 float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);
105 dac_code = (int32_t)float_code - LTC2636_offset;
108 return ((uint16_t)dac_code);
115 dac_voltage = ((float)(dac_code + LTC2636_offset)*
LTC2636_lsb);
116 return (dac_voltage);
123 *LTC2636_lsb = (voltage2 - voltage1) / ((
float) (dac_code2 - dac_code1));
124 temp_offset = voltage1/(*LTC2636_lsb) - (float)dac_code1;
125 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
126 *LTC2636_offset = (int16_t)temp_offset;
LTC2636: Octal 12-/10-/8-Bit SPI VOUT DACs with 10ppm/°C Reference.
static float LTC2636_lsb[9]
The LTC2636 lsb - index 8 for "all DACs".
Header File for Linduino Libraries and Demo Code.
static int16_t LTC2636_offset[9]
DAC offset - index 8 for "all DACs".
union LT_union_int32_4bytes data
float LTC2636_code_to_voltage(uint16_t dac_code, float LTC2636_lsb, int16_t LTC2636_offset)
Calculate the LTC2636 DAC output voltage given the DAC code, offset, and LSB value.
uint16_t LT_uint16
16-bit unsigned integer to be converted to two bytes
uint16_t LTC2636_voltage_to_code(float dac_voltage, float LTC2636_lsb, int16_t LTC2636_offset)
Calculate a LTC2636 DAC code given the desired output voltage, offset, and LSB value.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
void LTC2636_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2636_lsb, int16_t *LTC2636_offset)
Calculate the LTC2636 offset and LSB voltages given two measured voltages and their corresponding cod...
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 ...
void LTC2636_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2636.