116 #ifndef ENABLE_CALIBRATION 126 #define _BUTTON_WAIT_TIME 500 129 #define _BUTTON_TIME_1 4000 131 #define _BUTTON_TIME_2 2000 133 #define _VBUTTON_STEP_1 3 135 #define _VBUTTON_STEP_2 1 137 #define _IBUTTON_STEP_1 0.0000030 139 #define _IBUTTON_STEP_2 0.0000010 155 #ifndef ENABLE_CALIBRATION 165 const char chrCommands[][3],
166 int16_t sizeSerialCommands
172 for (i=0; i<sizeSerialCommands; i++)
174 if (chrCommands[i][0]==toupper(strData[0]) && chrCommands[i][1]==toupper(strData[1]) && chrCommands[i][2]==toupper(strData[2]))
176 if ((strchr1=strchr(strData,
':'))==NULL) strchr1=strchr(strData,
' ');
177 if (strchr1==NULL) strData[0]=
'\0';
178 else strcpy(strData,strchr1+1);
191 while (Serial.available()>0 && Serial.peek()!=
'\n' && Serial.peek()!=
'\r')
193 if (i<100) serialData[i++]= Serial.read();
198 if (Serial.peek()==
'\n')
201 if (Serial.peek()==
'\r') Serial.read();
205 if (Serial.peek()==
'\r')
208 if (Serial.peek()==
'\n') Serial.read();
215 #define SERIAL_COMMANDS_ERROR -1 239 uint8_t intSMUchan=
_CH0;
241 if (chrSerialData[0]==
'*')
243 #define SERIAL_COMMANDS_SIZE_0 2 249 enum {SERIAL_0_RST=0, SERIAL_0_IDN=1};
255 Serial.println(
"Reset");
259 for (int8_t iChan=
_CH0; iChan <=
_CH7; iChan++)
261 if (SMU[iChan].IsPresent())
263 Serial.print(
", CH");
275 #define SERIAL_COMMANDS_SIZE_1 9 288 enum {SERIAL_1_CH0=0, SERIAL_1_CH1=1, SERIAL_1_CH2=2, SERIAL_1_CH3=3, SERIAL_1_CH4=4, SERIAL_1_CH5=5, SERIAL_1_CH6=6, SERIAL_1_CH7=7, SERIAL_1_LCD=8 };
317 #ifndef ENABLE_CALIBRATION 318 #define SERIAL_COMMANDS_SIZE_LCD 2 324 enum {SERIAL_LCD_DIS=0, SERIAL_LCD_ENA=1};
328 Serial.println(F(
"Disabled"));
333 Serial.println(F(
"Enabled"));
340 #define SERIAL_COMMANDS_SIZE_12 6 350 enum {SERIAL_12_ENA=0, SERIAL_12_DIS=1, SERIAL_12_VOL=2, SERIAL_12_CUR=3, SERIAL_12_MEA=4, SERIAL_12_CAL=5};
354 #ifndef ENABLE_CALIBRATION 359 Serial.println(F(
"Enabled"));
367 Serial.println(F(
"Disabled"));
373 fValue=atof(chrSerialData);
377 #ifndef ENABLE_CALIBRATION 378 if (intSMUchan <=
_CH3)
385 Serial.println(fValue,4);
390 int8_t source_both_sink;
391 if (chrSerialData[0]==
'+')
394 fValue=atof(chrSerialData+1);
397 else if (chrSerialData[0]==
'-')
400 fValue=atof(chrSerialData+1);
406 fValue=atof(chrSerialData);
412 #ifndef ENABLE_CALIBRATION 413 if (intSMUchan <=
_CH3)
420 Serial.println(fValue,4);
424 #define SERIAL_COMMANDS_SIZE_121 2 431 enum {SERIAL_121_VOL=0, SERIAL_121_CUR=1};
439 dtostrf(SMU[intSMUchan].MeasureVoltage(),8,4,sDisplay);
440 Serial.println(sDisplay);
446 dtostre(SMU[intSMUchan].MeasureCurrent(),sDisplay,5,0);
447 Serial.println(sDisplay);
453 #define SERIAL_COMMANDS_SIZE_122 2 459 enum {SERIAL_122_SET=0, SERIAL_122_RES=1};
464 #ifdef ENABLE_CALIBRATION 467 Serial.println(F(
"Calibration not enabled."));
475 Serial.println(F(
"Calibration Restored"));
484 #ifndef ENABLE_CALIBRATION 504 step_size=step_size*16;
549 step_size=step_size*16;
580 uint32_t end_time=millis()+delay;
582 while ((int32_t)(millis()-end_time)<0)
584 #ifndef ENABLE_CALIBRATION 602 for (int8_t iChan=
_CH0; iChan <=
_CH7; iChan++)
605 if (SMU[iChan].present_ != 0)
615 #ifndef ENABLE_CALIBRATION 618 for (int8_t iChan=
_CH0; iChan <=
_CH7; iChan++)
620 if (SMU[iChan].present_ != 0)
642 for (int8_t iChan=
_CH0; iChan<=
_CH7; iChan++)
648 if (SMU[iChan].IsPresent()!=0)
650 #ifndef ENABLE_CALIBRATION 655 #ifndef ENABLE_CALIBRATION #define _EASYSMU_ID_STRING
ID string written to EasySMU EEPROM. Value that will be returned by *IDN? serial command.
#define I2C_Board3_LTC2485_Iout_LH_ADDR0
#define I2C_Board7_LTC2485_Vout_LF_ADDR0
float MeasureCurrent()
Measure the current (with ADC).
float MeasureVoltage()
Measure the voltage (with ADC).
LTC2655: Quad I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference.
int SMUselected_
stores which SMU channel is selected on the TFT display
The EasySMU class contains functions for interacting with the EasySMU source measurement unit...
#define I2C_Board5_LTC2485_Iout_LH_ADDR0
void codeStepVoltageSourceSetting(int16_t stepSize)
Increase or decrease the voltage source setting.
#define I2C_Board4_LTC2655_LLL_ADDR0
static void setup()
Initialize the Linduino, EasySMU, screen, etc.
static int16_t getToken(char strData[], const char chrCommands[][3], int16_t sizeSerialCommands)
Check if first three characters match a three character command in chrCommands.
LTC2485: 24-Bit Delta Sigma ADC with Easy Drive Input Current Cancellation and I2C Interface...
#define SERIAL_COMMANDS_SIZE_121
EasySMU SMU[8]
Array of eight EasySMU instances that hold state for up to eight stacked EasySMU shields.
#define I2C_Board0_EEPROM_ADDR0
#define _BUTTON_TIME_1
Touchscreen step size increases after _BUTTON_TIME_1 milliseconds. This allows faster user adjustment...
#define I2C_Board7_LTC2655_LLL_ADDR0
#define _PRINT_ERROR_CURRENT_SOURCE_SETTING
#define I2C_Board1_LTC2655_LLL_ADDR0
void fltStepCurrentSourceSetting(float fltStepSize)
Increase or decrease the current source setting by this value in amps.
#define I2C_Board3_EEPROM_ADDR0
#define I2C_Board3_LTC2485_Vout_LF_ADDR0
#define I2C_Board5_LTC2655_LLL_ADDR0
#define I2C_Board1_LTC2485_Iout_LH_ADDR0
Header File for Linduino Libraries and Demo Code.
#define I2C_Board7_EEPROM_ADDR0
#define _BUTTON_WAIT_TIME
Give the user 500ms to adjust a value before setting the output. This allows the user to adjust a val...
#define I2C_Board6_LTC2655_LLL_ADDR0
#define _PRINT_ERROR_VOLTAGE_SOURCE_SETTING
float flt_measured_current_
measured current (in amps)
#define I2C_Board6_LTC2485_Vout_LF_ADDR0
#define I2C_Board2_LTC2485_Vout_LF_ADDR0
#define I2C_Board3_LTC2655_LLL_ADDR0
#define QUIKEVAL_MUX_MODE_PIN
QUIKEVAL_MUX_MODE_PIN defines the control pin for the QuikEval MUX.
void DisplayMeasuredVoltage(int16_t channel, float flt_old, float flt_new)
Draw the measured voltage for a single channel.
int CheckButton()
check if a button is pressed
#define SERIAL_COMMANDS_SIZE_LCD
int8_t MeasureVoltageCurrent()
Measure the voltage and current (with ADCs).
#define I2C_Board6_EEPROM_ADDR0
#define _VBUTTON_STEP_2
Voltage step size after _BUTTON_TIME_2.
#define I2C_Board5_LTC2485_Vout_LF_ADDR0
#define I2C_Board4_EEPROM_ADDR0
#define I2C_Board4_LTC2485_Vout_LF_ADDR0
void i2c_enable()
i2c_enable or quikeval_I2C_init must be called before using any of the other I2C routines.
void DisplayMeasuredCurrent(int16_t channel, float flt_old, float flt_new)
Draw the measured current for a single channel.
#define I2C_Board6_LTC2485_Iout_LH_ADDR0
int8_t fltSetCommitVoltageSource(float fVoltage)
Commit the voltage source setting immediately to this float value.
int16_t ReadCalibration()
Read calibration from EEPROM.
static void ParseSerialData(char chrSerialData[])
Checks for the following valid commands from the serial interface and performs the corresponding acti...
void printError(int16_t errorNum)
Class Library Header File for EasySMU: I2C Address Translator Demonstration and a Simple Multi-Channe...
#define I2C_Board1_EEPROM_ADDR0
float fltReadCurrentSourceSetting()
Read the current source setting.
#define I2C_Board2_LTC2655_LLL_ADDR0
The EasySMU_IOpanel class provides an interface between the EasySMU and a touchscreen.
void DisplayVoltageSourceSetting(int16_t channel, float flt_old, float flt_new)
Draw the voltage source setting for a single channel.
int8_t SetCalibration()
Perform calibration.
#define I2C_Board5_EEPROM_ADDR0
void DisableOutput()
Disables the LT1970 output.
#define I2C_Board1_LTC2485_Vout_LF_ADDR0
#define I2C_Board4_LTC2485_Iout_LH_ADDR0
#define _VBUTTON_STEP_1
Voltage step size after _BUTTON_TIME_1.
float flt_measured_voltage_
measured voltage (in volts)
float fltReadVoltageSourceSetting()
Read the voltage source setting.
EasySMU_IOpanel IOpanel
IOpanel provides an interface between the EasySMU hardware and a touchscreen.
static void SetCurrent()
Check if the user is pressing the I+, I++, I-, or I– buttons. If so, adjust the current.
static void DelayAndUserInput(uint32_t delay)
Wait for 'delay' milliseconds while handling button presses on the touchscreen.
#define _LTC2485_CONVERSION_TIME
Use 1X mode conversion time for EasySMU conversions.
#define SERIAL_COMMANDS_SIZE_122
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
uint8_t enabled_
indicates if the TFT is enabled.
uint8_t RestoreFactoryCalibration()
Restore factory calibration from the EEPROM.
int8_t CommitVoltageSourceSetting()
Commit the voltage source setting.
char serial_data[100]
Used to buffer data from serial interface.
void Init()
Initialize the IO panel, including drawing buttons, etc.
static void SetVoltage()
Check if the user is pressing the V+, V++, V-, or V– buttons. If so, adjust voltage.
void EnableOutput()
Enables the LT1970 output.
int16_t PrintFactoryCalibrationInfo()
Prints the factory calibration info from EEPROM to the serial port.
#define I2C_Board2_LTC2485_Iout_LH_ADDR0
uint32_t duration_button_pressed_
stores a value corresponding to how long the button has been pressed
#define I2C_Board2_EEPROM_ADDR0
static void loop()
Arduino/Linduino loop that runs continuously.
int button_pressed_
stores the value of the button pressed (from enum)
void DisplayCurrentSourceSetting(int16_t channel, float flt_old, float flt_new, int8_t source_both_sink)
Draw the current source setting for a single channel.
#define _IBUTTON_STEP_1
Current step size after _BUTTON_TIME_1.
int8_t CommitCurrentSourceSetting()
Commit the current source setting.
#define SERIAL_COMMANDS_SIZE_0
boolean ReadLine(char *serialData)
Read available characters from the serial port and append the result to the *serialData string...
#define I2C_Board7_LTC2485_Iout_LH_ADDR0
#define SERIAL_COMMANDS_SIZE_1
#define I2C_Board0_LTC2485_Vout_LF_ADDR0
int8_t fltSetCommitCurrentSource(float fCurrent, int8_t up_down_both)
Change the current source setting immediately.
#define I2C_Board0_LTC2655_LLL_ADDR0
Header File for EasySMU_IOpanel Library That Enables Touchscreen Control of EasySMU.
#define _PRINT_ERROR_SERIAL_COMMAND
#define _IBUTTON_STEP_2
Current step size after _BUTTON_TIME_2.
#define I2C_Board0_LTC2485_Iout_LH_ADDR0
#define SERIAL_COMMANDS_SIZE_12