68 #define LTC2485_TIMEOUT (_LTC2485_CONVERSION_TIME) 70 EasySMU::EasySMU(uint8_t EEPROM_I2C_address_param, uint8_t DAC_I2C_address_param, uint8_t ADC_Vsense_I2C_address_param, uint8_t ADC_Isense_I2C_address_param)
90 if (code_voltage_setting<0)
94 else if (code_voltage_setting>0xFFFF)
108 int32_t code_voltage_setting =
Vdac_code_-step_size;
109 Vdac_code_ = (code_voltage_setting < 0x000) ? 0x0000 :
110 ((code_voltage_setting > 0xFFFF) ? 0xFFFF : (uint16_t) code_voltage_setting);
134 #define float_current_source_setting_equation(Idac_pullup_code,current_source_pullup_offset,current_source_pullup_LSB) (((int32_t)Idac_pullup_code_ + (int32_t)current_source_pullup_offset) * current_source_pullup_LSB) 140 if (code_current_pullup_setting<0)
144 else if (code_current_pullup_setting>0xFFFF)
155 if (code_current_pulldown_setting<0)
159 else if (code_current_pulldown_setting>0xFFFF)
193 if (flt_step_size > 0)
211 int32_t code_delta_pullup_pulldown_setting=code_current_pulldown_setting-code_current_pullup_setting;
213 if ((code_current_pullup_setting < 0x000) || (code_current_pulldown_setting < code_delta_pullup_pulldown_setting))
218 else if ((code_current_pullup_setting > (0xFFFF-code_delta_pullup_pulldown_setting)) || (code_current_pulldown_setting > 0xFFFF))
265 int32_t temperature_of_Iadc_code, temperature_of_Vadc_code;
347 Serial.print(prompt);
349 Serial.println(*flt_user_input,6);
363 float fltVsetP5V, fltVsetM5V;
364 int32_t lngVoutP5V, lngVoutM5V;
366 Serial.println(F(
"Connect to voltmeter and wait ten seconds."));
369 const uint16_t _VSET_P5V=44337, _VSET_M5V=15234;
370 const uint16_t _ISET=48000;
377 int32_t temperature_Vadc_code, temperature_Iadc_code;
385 int32_t lngThrowaway;
405 fltVoff=fltVoff/1000;
424 Serial.println(F(
"Disconnect meter. Press ENTER"));
442 Rout=-1*(lngIoutM5-lngIoutP5)/(
float)(lngVoutM5V-lngVoutP5V);
448 int32_t lngIout0V, lngVout0V;
461 uint16_t _ISET_8=48000;
462 int32_t lngIout8, lngVout8;
469 fltIout8=fltIout8/1000;
471 uint16_t _ISET_9=48000;
472 int32_t lngIout9, lngVout9;
479 fltIout9=fltIout9/1000;
494 fltIout8=fltIout8/1000;
501 fltIout9=fltIout9/1000;
507 fltIout8=-1*fltIout8/1000;
510 fltIout9=-1*fltIout9/1000;
520 Serial.print(F(
"Save calibration? (Y/N)"));
522 if (user_char!=
'y' || user_char!=
'Y')
528 Serial.println(F(
"Info: "));
529 Serial.setTimeout(30000);
530 size_t numbytes = Serial.readBytesUntil(
'\r', buffer,
CAL_INFO_STRLEN-1);
532 buffer[numbytes] =
'\0';
535 Serial.println(buffer);
536 Serial.setTimeout(1000);
548 while (Serial.peek()==
'\n' || Serial.peek()==
'\r') Serial.read();
550 Serial.println(F(
"Written"));
609 Serial.print(calInfo);
624 Serial.println(buffer);
635 for (i = 0; i < num_bytes; i++)
float current_source_pullup_LSB
the current of one LSB in amps from the current pullup DAC channel
uint8_t eeprom_read_byte_array(uint8_t i2c_address, char *data, uint16_t address, uint8_t num_bytes)
Read a data byte at address from the EEPROM with i2c_address.
float MeasureCurrent()
Measure the current (with ADC).
int8_t eeprom_poll(uint8_t i2c_address)
Determine if the EEPROM is ready for communication by writing the address+!write byte and looking for...
float MeasureVoltage()
Measure the voltage (with ADC).
uint8_t DAC_I2C_address_
I2C address of LTC2655 used to control voltage and current settings.
uint8_t eeprom_read_int16(uint8_t i2c_address, int16_t *read_data, uint16_t address)
Read the two byte integer data from the EEPROM starting at address.
int32_t current_measure_offset
the code from the current ADC that corresponds to 0A at the output
uint8_t eeprom_write_byte(uint8_t i2c_address, char data, uint16_t address)
Write the data byte to the EEPROM with i2c_address starting at EEPROM address.
float voltage_source_LSB
the voltage of one LSB in volts (from the voltage channel of the DAC)
void codeStepVoltageSourceSetting(int16_t stepSize)
Increase or decrease the voltage source setting.
void fltStepCurrentSourceSetting(float fltStepSize)
Increase or decrease the current source setting by this value in amps.
int16_t WriteCalibration()
Write calibration to EEPROM.
float flt_measured_current_
measured current (in amps)
#define _EASYSMU_VOLTAGE_DAC
uint8_t eeprom_write_byte_array(uint8_t i2c_address, char data[], uint16_t address, uint8_t num_bytes)
Write the data byte array to the EEPROM with i2c_address starting at EEPROM address.
int8_t MeasureVoltageCurrent()
Measure the voltage and current (with ADCs).
float current_measure_output_resistance
This value is used to modify the output current measurement result based on output voltage...
int16_t IsPresent()
Check if this EasySMU is present.
int8_t codeSetCommitVoltageSource(int32_t lngVoltageSetParam)
Set and commit the voltage source setting immediately.
int16_t current_source_pulldown_offset
current DAC code that ideally would result in 0A at output, if the output current could be configured...
int8_t fltSetCommitVoltageSource(float fVoltage)
Commit the voltage source setting immediately to this float value.
int16_t ReadCalibration()
Read calibration from EEPROM.
union LT_union_int32_4bytes data
Class Library Header File for EasySMU: I2C Address Translator Demonstration and a Simple Multi-Channe...
uint8_t ADC_Vsense_I2C_address_
I2C address of LTC2485 used to measure output voltage.
float fltReadCurrentSourceSetting()
Read the current source setting.
float float_current_source_setting_
Current source setting.
union EasySMU::eeprom_data_union eeprom
#define _EASYSMU_CURRENT_PULLDOWN_DAC
Channel C of the DAC configures the maximum pulldown current.
int32_t Iadc_code_
raw code of current ADC
int8_t LTC2485_read(uint8_t i2c_address, uint8_t adc_command, int32_t *adc_code, uint16_t eoc_timeout)
Reads from LTC2485 ADC that accepts an 8 bit configuration and returns a 24 bit result.
uint8_t eeprom_read_byte(uint8_t i2c_address, char *data, uint16_t address)
Read a data byte at address from the EEPROM with i2c_address.
int8_t SetCalibration()
Perform calibration.
int8_t LTC2655_write(uint8_t i2c_address, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write a 16-bit dac_code to the LTC2655.
#define _LTC2485_CONVERSION_TIME_1X
void DisableOutput()
Disables the LT1970 output.
EasySMU(uint8_t EEPROM_I2C_address_param, uint8_t DAC_I2C_address_param, uint8_t ADC_Vsense_I2C_address_param, uint8_t ADC_Isense_I2C_address_param)
EasySMU constructor. Remember each EasySMU instance has unique I2C addresses, so this configures each...
float voltage_measure_LSB
the voltage of one LSB in volts from the voltage ADC
#define EEPROM_CAL_STATUS_ADDRESS
float flt_measured_voltage_
measured voltage (in volts)
float fltReadVoltageSourceSetting()
Read the voltage source setting.
#define EEPROM_FACTORY_CAL_STATUS_ADDRESS
A backup version of the factory calibration is stored at this address. Factory calibration may be rec...
float current_measure_LSB
the current of one LSB in amps from the current ADC
void ResetCalibration()
Reset the calibration to a typical value.
int8_t SetCalibrationSinglePoint(uint16_t voltageSetValue, uint16_t currentSetValue, const char prompt[], float *fltUserOutput, int32_t *lngVadc_code, int32_t *lngIadc_code)
Configure a voltage and current setting and prompt for measurement from lab-grade multimeter...
int16_t cal_key
If this is set to the proper value, it indicates that a calibration has been performed.
int16_t WriteFactoryCalibration()
FOR FACTORY USE ONLY! Write calibration to factory calibration section of EEPROM. ...
float flt_temperature_of_Iadc_
current output setting (float)
#define float_current_source_setting_equation(Idac_pullup_code, current_source_pullup_offset, current_source_pullup_LSB)
void MeasureTemperatureOfADCs()
Measure the temperature of the voltage and current ADCs.
uint8_t RestoreFactoryCalibration()
Restore factory calibration from the EEPROM.
int8_t CommitVoltageSourceSetting()
Commit the voltage source setting.
#define LTC2485_INTERNAL_TEMP
#define LTC2485_TIMEOUT
Maximum time allowed for LTC2485 conversion. If this time is exceeded, something is wrong...
void EnableOutput()
Enables the LT1970 output.
uint8_t EasySMU_EEPROM_I2C_address_
I2C address of the EEPROM that stores calibration data.
#define EEPROM_FACTORY_CAL_INFO_ADDRESS
Channel ID information returned by *IDN? command.
#define LTC2655_CMD_WRITE_UPDATE
int16_t PrintFactoryCalibrationInfo()
Prints the factory calibration info from EEPROM to the serial port.
int32_t voltage_measure_offset
the voltage ADC code that corresponds to 0V at the output
prompt
Used to keep track to print voltage or print code.
int32_t temperature_Vadc_code
This is the temperature code read from the voltage ADC during calibration.
int8_t present_
Indicates if this channel is present.
Union that defines the calibration data stored in the EasySMU EEPROM.
#define CAL_INFO_STRLEN
Defines length of the calibartion info string (serial number) which is stored in the EEPROM...
uint16_t Idac_pulldown_code_
raw code of current pulldown DAC
float flt_temperature_of_Vadc_
Temperature of voltage ADC.
int32_t temperature_Iadc_code
This is the temperature code read from the current ADC during calibration.
#define _EASYSMU_ENABLE_OUTPUT_DAC
Channel D of the DAC is used to enable or disable the LTC1970's output. It is essentially used as a b...
int16_t voltage_source_offset
The output voltage is 0V when this code is stored in the voltage channel of the DAC.
int16_t current_source_pullup_offset
current DAC code that ideally would result in 0A at output, if the output current could be configured...
int8_t CommitCurrentSourceSetting()
Commit the current source setting.
uint16_t Idac_pullup_code_
raw code of current pullup DAC
struct EasySMU::eeprom_data_union::data_struct_type calibration
uint16_t Vdac_code_
raw code of voltage DAC
uint8_t ADC_Isense_I2C_address_
I2C address of LTC2485 used to measure output current.
int32_t Vadc_code_
raw code of voltage ADC
int8_t fltSetCommitCurrentSource(float fCurrent, int8_t up_down_both)
Change the current source setting immediately.
float current_source_pulldown_LSB
the current of one LSB in amps from the current pulldown DAC channel
#define _EASYSMU_CURRENT_PULLUP_DAC
Channel B of the DAC configures the maximum pullup current.
char byte_array[sizeof(data_struct_type)]
int16_t WriteFactoryCalibrationInfo(char *buffer)
Write factory calibration info to EEPROM.