118 Serial.begin(115200);
132 if (Serial.available())
135 if (user_command !=
'm')
136 Serial.println(user_command);
138 switch (user_command)
147 Serial.println(
"Incorrect Option");
151 Serial.println(
"Error: No Acknowledge. Check I2C Address.");
153 Serial.println(
"***************************");
165 Serial.println(
"*****************************************************************");
166 Serial.println(
"* DC1208 Demonstration Program *");
167 Serial.println(
"* *");
168 Serial.println(
"* This program communicates with the LTC4151 High Voltage I2C *");
169 Serial.println(
"* Current and Voltage Monitor found on the DC1208A demo board. *");
170 Serial.println(
"* Set the baud rate to 115200 and select the newline terminator.*");
171 Serial.println(
"* *");
172 Serial.println(
"*****************************************************************");
179 Serial.println(
"1-Read Continuous Mode");
180 Serial.println(
"2-Read Snapshot Mode");
182 Serial.print(
"Enter a command: ");
206 uint16_t current_sense_adc_code, vin_adc_code, adin_adc_code;
212 float current, VIN_voltage, ADIN_voltage;
220 Serial.println(
"***************************");
221 Serial.print(
"Load Current: ");
222 Serial.print(current);
223 Serial.println(
" A\n");
225 Serial.print(
"VIN Voltage: ");
226 Serial.print(VIN_voltage);
227 Serial.println(
" V\n");
229 Serial.print(
"ADIN Voltage: ");
230 Serial.print(ADIN_voltage);
231 Serial.println(
" mV\n");
233 Serial.println(
"m-Main Menu");
236 while (Serial.available() ==
false);
252 Serial.println(
"***************************");
253 Serial.println(
"Snapshot Mode");
254 Serial.println(
"1-Load Current:");
255 Serial.println(
"2-V_IN Voltage:");
256 Serial.println(
"3-ADIN Voltage:");
257 Serial.println(
"m-Main Menu");
258 Serial.print(
"Enter a command: ");
262 if (user_command ==
'm')
265 Serial.println(user_command);
268 uint16_t current_sense_adc_code, vin_adc_code, adin_adc_code;
269 float current, VIN_voltage, ADIN_voltage;
272 switch (user_command)
279 Serial.print(
"Load Current: ");
280 Serial.print(current);
281 Serial.println(
" A\n");
288 Serial.print(
"VIN Voltage: ");
289 Serial.print(VIN_voltage);
290 Serial.println(
" V\n");
297 Serial.print(
"ADIN Voltage: ");
298 Serial.print(ADIN_voltage);
299 Serial.println(
" mV\n");
302 if (user_command !=
'm')
303 Serial.println(
"Incorrect Option");
308 while ((user_command !=
'm') && (ack == 0));
static void loop()
Repeats Linduino loop.
static void print_prompt()
Prints main menu.
unsigned char user_command
const float resistor
Sense resistor value.
#define LTC4151_ADIN_MSB_REG
const float LTC4151_adin_lsb
Typical ADIN lsb weight in mV.
static int8_t menu_2_snapshot_mode()
Reads inputs in snapshot mode.
Header File for Linduino Libraries and Demo Code.
static uint8_t channel
LTC2305 Channel selection.
float LTC4151_code_to_ADIN_voltage(uint16_t adc_code, float LTC4151_adin_lsb)
Calculates the LTC4151 ADIN voltage in mV given "LTC4151_adin_lsb" LSB weight in mV.
int8_t LTC4151_write(uint8_t i2c_address, uint8_t adc_command, uint8_t code)
Write one byte to an LTC4151 register.
const float LTC4151_sense_lsb
Typical sense lsb weight in volts.
LTC4151: High Voltage I2C Current and Voltage Monitor.
static int8_t demo_board_connected
Set to 1 if the board is connected.
int8_t LTC4151_read_12_bits(uint8_t i2c_address, uint8_t adc_command, uint16_t *adc_code)
Reads a 12-bit value from LTC4151.
float LTC4151_code_to_vin_voltage(uint16_t adc_code, float LTC4151_vin_lsb)
Calculates the LTC4151 V_IN voltage given "LTC_vin_lsb" LSB weight in volts.
static int8_t menu_1_continuous_mode()
Reads all inputs in continuous mode.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
static void setup()
Initialize Linduino.
#define LTC4151_I2C_ADDRESS
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
const float LTC4151_vin_lsb
Typical Vin lsb weight in volts.
static void print_title()
Prints the title block when program first starts.
#define LTC4151_SENSE_MSB_REG
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
#define LTC4151_VIN_CHANNEL_REG
static int8_t LTC4151_snapshot(uint8_t i2c_address, uint8_t channel)
Build and send the snapshot command.
#define LTC4151_SENSE_CHANNEL_REG
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
float LTC4151_code_to_sense_current(uint16_t adc_code, float resistor, float LTC4151_sense_lsb)
Calculates the LTC4151 sense current in Amps given "resistor" value in ohms and "LTC4151_sense_lsb" L...
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
#define LTC4151_CONTINUOUS_MODE
#define LTC4151_VIN_MSB_REG
static uint16_t current
the current measurement from the LTC3335's counter test mode.
#define LTC4151_CONTROL_REG
#define LTC4151_SNAPSHOT_MODE
#define LTC4151_ADIN_CHANNEL_REG