82 #define LTC6115_GPIO QUIKEVAL_GPIO 113 Serial.begin(115200);
118 if (!demo_board_connected)
120 Serial.println(F(
"EEPROM not detected, will attempt to proceed"));
121 demo_board_connected = 1;
159 TCCR1B |= (1 << WGM12);
160 TCCR1B |= (1 << CS12) | (1 << CS10);
161 TIMSK1 |= (1 << OCIE1A);
180 Serial.print(VinVolts,3);
182 Serial.print(IinAmps,3);
197 if (Serial.available())
201 Serial.println(user_command);
202 switch (user_command)
223 Serial.println(
"Invalid Option");
236 if (Serial.available())
279 Serial.print(
"VIN Input Voltage, Isense Current: ");
280 Serial.print(VinVolts, 4);
281 Serial.print(
"V , ");
282 Serial.print(IinAmps, 4);
294 Serial.print(F(
" Enter Voltage Gain (V/V): "));
297 Serial.println(user_command);
298 if (user_command < 0 || user_command > 199)
299 Serial.println(F(
" Input should be from 0 to 199."));
303 Serial.print(F(
" Voltage gain has been set to "));
304 Serial.println(user_command);
316 Serial.print(F(
" Enter Transimpedance Gain (V/A): "));
319 Serial.println(user_command);
320 if (user_command < 0 || user_command > 20000)
321 Serial.println(F(
" Input should be from 0 to 20000."));
325 Serial.print(F(
" Transimpedance has been set to "));
326 Serial.println(user_command);
336 Serial.print(
"Enter desired sample interval between 10 and 1000(ms): ");
341 while (update_interval < 10 || update_interval > 1000)
343 Serial.println(
"Invalid sampling interval.");
344 Serial.print(
"Enter desired sample interval between 10 and 1000(ms): ");
355 compare_reg = (int) ((16000000.0/((
float)frequency * 1024.0)) - 1.0);
377 Serial.print(
"Enter desired number of samples: ");
382 Serial.println(
"Elapsed ms, V, I");
435 Serial.println(F(
"*****************************************************************"));
436 Serial.println(F(
"* LTC6115 *"));
437 Serial.println(F(
"* *"));
438 Serial.println(F(
"* This program demonstrates how to work with the LTC6115. *"));
439 Serial.println(F(
"* *"));
440 Serial.println(F(
"* Set the baud rate to 115200 and select the newline terminator.*"));
441 Serial.println(F(
"* *"));
442 Serial.println(F(
"*****************************************************************"));
450 Serial.println(F(
"\n\n"));
451 Serial.println(F(
"*************************"));
452 Serial.println(F(
"1 - Convert and Read V and I (Single Sample)"));
453 Serial.print(F(
"2 - Change V Gain (Current setting: "));
455 Serial.println(F(
" V/V)"));
456 Serial.print(F(
"3 - Change I Gain (Current setting: "));
458 Serial.println(F(
" V/A, divide by Rsense for V/V)"));
459 Serial.print(F(
"4 - Change Sampling Period (Current setting: "));
461 Serial.println(F(
"ms)"));
462 Serial.println(F(
"5 - Begin Continuous V and I Sampling Conversion Readings (For Specified # of Samples)"));
463 Serial.println(F(
"6 - Stop Sampling"));
464 Serial.print(F(
"\nEnter a command: "));
static void menu_4_changeSampleFreq()
Changes the sampling frequency (ms)
static void menu_3_changeIGain()
Select current channel transimpedance gain (V/A)
static void menu_2_changeVGain()
volatile float current_millis
Number of elapsed milliseconds since the program started running.
unsigned char user_command
#define LTC6115_IIN
Maps to DC2026 J7.1, ADC channel 1.
void LTC6115ChangeIGain(float val)
This function changes the Current gain.
Header File for Linduino Libraries and Demo Code.
float LTC6115ToVolts(uint32_t val)
This function converts ADC code to Voltage without the converted voltage print statement.
float LTC6115ConvertToVolts(uint32_t val)
This function converts ADC code to Voltage.
void LTC6115_initialize()
This function will initialize 6115 variables.
float LTC6115ToAmps(uint32_t val)
This function converts ADC code to Current without the converted current print statement.
volatile int ISR_prompt_flag
Set to 1 to print prompt after interrupt service completes.
static int update_interval
Sampling interval(ms) to update to.
volatile float globaltime_ms
Number of elapsed milliseconds since menu 4 function is called.
float getIGain()
This function returns the current gain (V/A).
#define LTC6115_VIN
Pin Mapping.
volatile int num_samples
Total number of samples that the user desires.
volatile int print_flag
Set to 1 to print sampling data for menu option 4.
#define LTC6115_GPIO
Linduino QuikEval GPIO pin (QuikEval connector pin 14) connects to Arduino pin 9. ...
static void update_compare_reg(uint32_t regVal)
Updates the compare match register.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
uint32_t millsToHz(uint32_t val)
This function converts milliseconds to frequency (Hz).
static void print_title()
Prints the title block when program first starts.
static void loop()
Repeats Linduino loop.
volatile int ISR_flag
Set to 1 when interrupt service routine is running.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
volatile uint32_t readI
Stores current reading.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
float getVGain()
This function returns the voltage gain (V/V).
void LTC6115ChangeVGain(float val)
This function changes the Voltage gain.
LTC6115 High Voltage High Side Current and Voltage Sense.
static void print_prompt()
Prints main menu.
volatile uint32_t readV
Stores voltage reading.
volatile float start_millis
Start time when menu 4 function is called.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
volatile int samples_counter
Counts the number of samples taken.
static void setup()
Initialize Linduino.
static int compare_reg
Value to set compare match register to get desired interrupt frequency (Hz)
static void menu_6_stopSampling()
Stops the sampling from menu 5.
ISR(TIMER1_COMPA_vect)
Timer Compare Interrupt Service Routine.
static void menu_5_pipeToFile()
Pipes voltage and current reading results to a file.
static float menu_1_convert_read()
Read channel.
float LTC6115ConvertToAmps(uint32_t val)
This function converts ADC code to Current.
static uint8_t demo_board_connected
Set to 1 if the board is connected.