Compare commits

...

4 Commits

Author SHA1 Message Date
JayC319 fbb98c3c24 [update] fix cali_DAC mode 2022-08-22 13:46:17 +08:00
ROY c8c101ae98 [update] fix CC mode and CP mode 2022-08-18 18:50:19 +08:00
JayC319 ad1ed81f00 [update] cali mode stop issue fixed 2022-08-17 10:09:02 +08:00
ROY 69416bc58e [update] merge cali mode branch 2022-08-16 11:37:04 +08:00
10 changed files with 218 additions and 216 deletions
@@ -44,6 +44,8 @@ extern "C" {
#define E_LATCH_OFF LOAD2, D6
#define E_LATCH_VOUT_SMALL_ON LOAD2, D7
#define HIGH_Z_OPEN() latch_single_ctrl(E_LATCH_HIGH_Z, 0);
#define HIGH_Z_CLOSE() latch_single_ctrl(E_LATCH_HIGH_Z, 1);
uint8_t update_latch_stat(uint8_t latch, uint8_t dio, uint8_t value);
uint8_t latch_single_ctrl(uint8_t latch, uint8_t dio, uint8_t value);
uint8_t latch_multi_ctrl(void);
@@ -9,8 +9,8 @@ extern "C" {
#define ADC_CH_CURR AIN0_GND
#define ADC_CH_VIN AIN1_GND
#define ADC_CH_VOUT AIN2_GND
#define ADC_CH_BAT AIN3_GND
#define ADC_CH_VOUT AIN2_GND
#define MEASURE_CURRENT() read_adc_data(ADC_CH_CURR, FSR3)
#define MEASURE_VOLT() read_adc_data(ADC_CH_VIN, FSR3)
@@ -86,7 +86,7 @@ static void WorkModeLED()
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_CYAN);
break;
case CURVE_CALI_ADC:
case CURVE_CALI:
if (instru.AdcChannel == RIS_ADC_IIN) {
led_color_set(LED_NB_MAX, LED_BR_LV1, LED_CLR_RED);
} else if (instru.AdcChannel == RIS_ADC_VIN) {
@@ -205,6 +205,17 @@ struct wm_ocp_ctx_t {
struct wm_meas_t measure;
};
struct wm_adc_cali_ctx_t {
struct wm_meas_t measure;
uint16_t _cali_count;
int32_t _ADCValueSUM;
};
#define GET_ADC_SUM(_m) (((struct wm_adc_cali_ctx_t *)(_m))->_ADCValueSUM)
#define GET_CALI_COUNT(_m) (((struct wm_adc_cali_ctx_t *)(_m))->_cali_count)
struct wm_cp_ctx_t {
/* WARNING: please keep MEASURE at first!! */
struct wm_meas_t measure;
@@ -708,6 +719,29 @@ static int __ocp_create(void)
return 0;
}
static int __adc_cali_create()
{
struct wm_meas_t *m;
struct wm_adc_cali_ctx_t *p;
void **wm = &workMode_p;
p = malloc(sizeof(struct wm_adc_cali_ctx_t));
if (!p) return -1;
m = (struct wm_meas_t *)p;
m->_measureCurrent = 0;
m->_measureVin = 0;
m->_measureVout = 0;
m->_measureBat = 0;
m->_VoViSwitch = instru.VoViSwitch;
p->_ADCValueSUM = 0;
p->_cali_count = 0;
*wm = p;
return 0;
}
static int __cp_create(void)
{
struct wm_meas_t *m;
@@ -800,6 +834,9 @@ int wm_init(void)
case CURVE_DPV_ADVANCE_SMPRATE:
if (__dpv_advance_create()) return -2;
break;
case CURVE_CALI:
if (__adc_cali_create()) return -2;
break;
case CURVE_CP:
if (__cp_create()) return -2;
@@ -38,7 +38,7 @@ enum all_mode_e {
CURVE_DPV_ADVANCE = 0x10,
CURVE_DPV_ADVANCE_SMPRATE = 0x11,
CURVE_CALI_ADC = 0xF1, // Cali ADC - test
CURVE_CALI = 0xF1,
SET_SAMPLE_RATE = 0xE0,
@@ -663,8 +663,6 @@ static void Vout_Plot(void)
static void cali_IT_plot(void) {
void *wm = wm_get();
static int32_t ADCValueSUM = 0;
static uint16_t cali_count = 0;
static uint8_t ADC_cnt = 0;
static uint8_t rec_cnt = 0;
static uint16_t cali_count_max = 1000;
@@ -694,8 +692,8 @@ static void cali_IT_plot(void) {
if (curr_rec_en == false) {
rec_cnt++;
} else {
if (cali_count >= cali_count_max) {
ADCValueAVG = ADCValueSUM / cali_count;
if (GET_CALI_COUNT(wm) >= cali_count_max) {
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
SendNotify();
@@ -710,19 +708,19 @@ static void cali_IT_plot(void) {
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
PeriodicEvent = false;
ADCValueSUM = 0;
cali_count = 0;
ModeLED(NO_EVENT);
} else {
cali_count++;
ADCValueSUM = ADCValueSUM + MEAS_CURR(wm);
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
InputNotify(NOTIFY_VOLT, ADCValueSUM);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
GET_CALI_COUNT(wm)++;
GET_ADC_SUM(wm) = GET_ADC_SUM(wm) + MEAS_CURR(wm);
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
InputNotify(NOTIFY_VOLT, MEAS_CURR(wm));
InputNotify(NOTIFY_IMPEDANCE, (int32_t)GET_CALI_COUNT(wm));
}
}
if (rec_cnt == 2) {
volt_rec_en = true;
curr_rec_en = true;
rec_cnt = 0;
}
@@ -751,8 +749,6 @@ static void cali_IT_plot(void) {
static void cali_VT_plot(void) {
void *wm = wm_get();
static int32_t ADCValueSUM = 0;
static uint16_t cali_count = 0;
static uint8_t ADC_cnt = 0;
static uint8_t rec_cnt = 0;
uint16_t cali_count_max = 0;
@@ -780,8 +776,8 @@ static void cali_VT_plot(void) {
if (volt_rec_en == false) {
rec_cnt++;
} else {
if (cali_count >= cali_count_max) {
ADCValueAVG = ADCValueSUM / cali_count;
if (GET_CALI_COUNT(wm) >= cali_count_max) {
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
InputNotify(NOTIFY_VOLT, ADCValueAVG);
SendNotify();
@@ -796,20 +792,21 @@ static void cali_VT_plot(void) {
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
PeriodicEvent = false;
ADCValueSUM = 0;
cali_count = 0;
ModeLED(NO_EVENT);
} else {
cali_count++;
ADCValueSUM = ADCValueSUM + MEAS_VIN(wm);
GET_CALI_COUNT(wm)++;
GET_ADC_SUM(wm) = GET_ADC_SUM(wm) + MEAS_VIN(wm);
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
InputNotify(NOTIFY_VOLT, MEAS_VIN(wm));
InputNotify(NOTIFY_CURRENT, ADCValueSUM);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)GET_CALI_COUNT(wm));
}
}
if (rec_cnt == 2) {
volt_rec_en = true;
curr_rec_en = true;
rec_cnt = 0;
}
ADC_cnt++;
@@ -833,20 +830,29 @@ static void cali_VT_plot(void) {
return;
}
static void count_sum_clear(void) {
void *wm = wm_get();
if(wm) {
GET_CALI_COUNT(wm) = 0;
GET_ADC_SUM(wm) = 0;
}
return;
}
static void cali_Vout_plot(void) {
void *wm = wm_get();
static int32_t ADCValueSUM = 0;
static uint16_t cali_count = 0;
static uint8_t ADC_cnt = 0;
static uint8_t rec_cnt = 0;
uint16_t cali_count_max = 1000;
uint16_t cali_count_max = 2000;
int32_t ADCValueAVG = 0;
/* ADC_cnt: 0 - read Vin and do NOT buffer the Vin after changing gain twice
* 1 - read Vin and increase ADC_cnt
* 2 - read Vin and reset ADC_cnt
*/
if(vscanReset)
return;
if (ADC_cnt == 0) {
ADC_rxbuf = MEASURE_DAC();
@@ -855,36 +861,36 @@ static void cali_Vout_plot(void) {
if (volt_rec_en == false) {
rec_cnt++;
} else {
if (cali_count >= cali_count_max) {
ADCValueAVG = ADCValueSUM / cali_count;
// if (!GET_CALI_COUNT(wm) && GET_CALI_COUNT(wm) != 0) {
InputNotify(NOTIFY_VOLT, ADCValueAVG);
SendNotify();
// ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
// InputNotify(NOTIFY_CURRENT, ADCValueAVG);
// SendNotify();
uint8_t CIS_buf[9] = {0};
CIS_buf[0] = 5; //data len
CIS_buf[1] = instru.chip_id;
CIS_buf[2] = (uint8_t) ((ADCValueAVG & 0xFF00) >> 8);
CIS_buf[3] = (uint8_t) (ADCValueAVG & 0x00FF);
CIS_buf[4] = 0x00;
CIS_buf[5] = instru.VinADCGainLv;
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
// uint8_t CIS_buf[9] = {0};
// CIS_buf[0] = 5; //data len
// CIS_buf[1] = instru.chip_id;
// CIS_buf[2] = (uint8_t) ((ADCValueAVG & 0xFF00) >> 8);
// CIS_buf[3] = (uint8_t) (ADCValueAVG & 0x00FF);
// CIS_buf[4] = 0x00;
// CIS_buf[5] = instru.VinADCGainLv;
// SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
PeriodicEvent = false;
ADCValueSUM = 0;
cali_count = 0;
ModeLED(NO_EVENT);
} else {
cali_count++;
ADCValueSUM = ADCValueSUM + MEAS_VOUT(wm);
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm));
InputNotify(NOTIFY_CURRENT, ADCValueSUM);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
}
// PeriodicEvent = false;
// ModeLED(NO_EVENT);
// } else {
GET_CALI_COUNT(wm)++;
GET_ADC_SUM(wm) = GET_ADC_SUM(wm) + MEAS_VOUT(wm);
ADCValueAVG = GET_ADC_SUM(wm) / GET_CALI_COUNT(wm);
InputNotify(NOTIFY_VOLT, MEAS_VOUT(wm));
InputNotify(NOTIFY_CURRENT, ADCValueAVG);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)GET_CALI_COUNT(wm));
// }
}
if (rec_cnt == 2) {
volt_rec_en = true;
curr_rec_en = true;
rec_cnt = 0;
}
ADC_cnt++;
@@ -4,9 +4,9 @@
#define VERSION_DATE_YEAR 22
#define VERSION_DATE_MONTH 8
#define VERSION_DATE_DAY 11
#define VERSION_DATE_HOUR 15
#define VERSION_DATE_MINUTE 58
#define VERSION_DATE_DAY 22
#define VERSION_DATE_HOUR 13
#define VERSION_DATE_MINUTE 46
// this is NOT the version hash !!
// it's the last version hash
@@ -894,14 +894,16 @@ static void update_ZM_instruction(uint8 *ins) {
switch(ins[4]) {
case 0x00 : {
if (PeriodicEvent) {
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // 0 => open high_z mode
//latch_single_ctrl(E_LATCH_HIGH_Z, 0); // 0 => open high_z mode
HIGH_Z_OPEN();
}
break;
}
case 0x01 : {
if (PeriodicEvent) {
latch_single_ctrl(E_LATCH_HIGH_Z, 1); // 1 => close high_z mode
//latch_single_ctrl(E_LATCH_HIGH_Z, 1); // 1 => close high_z mode
HIGH_Z_CLOSE();
}
break;
}
@@ -918,29 +920,50 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case CURVE_CALI_ADC: {
case CURVE_CALI: {
switch(ins[3]) {
case RIS_ADC_IIN : { // 0x00
instru.eliteFxn = CURVE_CALI_ADC;
instru.eliteFxn = CURVE_CALI;
instru.AdcChannel = RIS_ADC_IIN;
instru.notifyRate = 1000;
ModeLED(WORKING);
break;
}
case RIS_ADC_VIN : { // 0x01
instru.eliteFxn = CURVE_CALI_ADC;
instru.eliteFxn = CURVE_CALI;
instru.AdcChannel = RIS_ADC_VIN;
instru.notifyRate = 1000;
ModeLED(WORKING);
break;
}
case RIS_DAC_VOUT : { // 0x02
instru.eliteFxn = CURVE_CALI_ADC;
instru.eliteFxn = CURVE_CALI;
instru.AdcChannel = RIS_DAC_VOUT;
instru.notifyRate = 1000;
instru.VoltConstant = ( ((uint16_t)(ins[4])) << 8) | (uint16_t)(ins[5]); // output voltage
instru.hign_z_en = 1;
switch(ins[4]) {
case 0x00: {
instru.VoltConstant = 0x2710;
break;
}
case 0x01: {
instru.VoltConstant = 0x61A8;
break;
}
case 0x02: {
instru.VoltConstant = 0xC350;
break;
}
case 0x03: {
instru.VoltConstant = 0xEA60;
break;
}
}
DAC0_W_T(instru.VoltConstant);
ModeLED(WORKING);
count_sum_clear();
break;
}
default : {
@@ -1370,60 +1393,7 @@ static void update_ZM_instruction(uint8 *ins) {
if (led_item == DEV_LED_LIGHT_COLOR)
led_color_code_set(LED_NB_MAX, LED_BR_LV8, &led_c);
break;
}
case 0x50: {
initCISBuf();
cis_buf[0] = 2;
cis_buf[1] = (uint8_t) ADC_rxbuf >> 8;
cis_buf[2] = (uint8_t) ADC_rxbuf;
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
break;
}
case 0x51: {
initCISBuf();
cis_buf[0] = 2;
cis_buf[1] = (uint8_t) ADC_rxbuf >> 8;
cis_buf[2] = (uint8_t) ADC_rxbuf;
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf);
break;
}
case 0x61: {
dac_ldac_mode(ins[4], ins[5]);
break;
}
case 0x62: {
dac_clear_mode();
break;
}
case 0x63: {
dac_power_control_mode(ins[4], ins[5], ins[6]);
break;
}
case 0x64: {
dac_linearity_mode(ins[4]);
break;
}
case 0x65: {
uint16_t volts = (uint16_t)ins[6] << 8 | ins[7];
dac_write_mode(ins[4], ins[5], volts);
break;
}
case 0x66: {
uint16_t volts = (uint16_t)ins[6] << 8 | ins[7];
DAC0_W_T(volts);
break;
}
@@ -57,7 +57,7 @@ static void device_init(void)
(instru.eliteFxn == CURVE_CA) || \
(instru.eliteFxn == CURVE_VO) || \
(instru.eliteFxn == CURVE_OCP) || \
(instru.eliteFxn == CURVE_CALI_ADC) \
(instru.eliteFxn == CURVE_CALI) \
)
#define Ve1MatchVe2Mode() ( \
@@ -76,9 +76,15 @@ static void peri_mode(void)
vscanReset = true;
if (first_highz_flag && GPT.cnt_lead_time >= 1000) {
if (instru.eliteFxn == CURVE_OCP || instru.eliteFxn == CURVE_CC || instru.eliteFxn == CURVE_CP) {
latch_single_ctrl(E_LATCH_HIGH_Z, 0); // HIGH Z MODE // 1: close; 0: open;
HIGH_Z_OPEN(); // HIGH Z MODE // 1: close; 0: open;
} else {
latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
//latch_single_ctrl(E_LATCH_HIGH_Z, instru.hign_z_en); // HIGH Z MODE // 1: close; 0: open;
if(instru.hign_z_en == 1) {
HIGH_Z_CLOSE();
}
else{
HIGH_Z_OPEN();
}
}
first_highz_flag = false;
}
@@ -126,7 +132,7 @@ static void peri_mode(void)
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
(instru.eliteFxn == CURVE_CALI_ADC)) {
(instru.eliteFxn == CURVE_CALI)) {
batteryCheck_flag = false;
tempCheck_flag = false;
@@ -230,7 +236,7 @@ static void uni_pulse_mode(void)
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
(instru.eliteFxn == CURVE_CALI_ADC)) {
(instru.eliteFxn == CURVE_CALI)) {
batteryCheck_flag = false;
tempCheck_flag = false;
@@ -533,7 +539,7 @@ static void EliteADCControl(uint32_t time)
}
break;
case CURVE_CALI_ADC:
case CURVE_CALI:
if (instru.AdcChannel == RIS_ADC_IIN) {
cali_IT_plot();
} else if (instru.AdcChannel == RIS_ADC_VIN) {
@@ -591,7 +597,9 @@ static void mode_done(void)
(instru.eliteFxn == CURVE_DPV) ||
(instru.eliteFxn == CURVE_DPV_SMPRATE) ||
(instru.eliteFxn == CURVE_DPV_ADVANCE) ||
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE)) {
(instru.eliteFxn == CURVE_DPV_ADVANCE_SMPRATE) ||
(instru.eliteFxn == CURVE_CALI))
{
if (!PeriodicEvent) {
finishMode = true;
SendNotify();
@@ -202,74 +202,67 @@ static void cc_vscan(void)
static int32_t i_set = 0;
if (vscanReset) {
Vset = 0;
if (cc->_charge == 0) {
i_set = cc->_Iset * (-1);
} else if(cc->_charge == 1) {
} else {
i_set = cc->_Iset;
}
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
Voutin = m->_measureVout * 200; //[5nV]
// if (cc_resistance == 1) //vout has 100R
Vset = Voutin + (i_set * RESISTANCE_100R); //[5nV]
// else
// Vset = Voutin; //[5nV]
if (Vset >= 1100000000) { // 5.5V
Vset = 1100000000;
} else if (Vset <= -1000000000) { //-5V
Vset = -1000000000;
}
return;
}
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
deltaI = Iin - i_set;
if (deltaI > 400000 || deltaI < -400000) { //20uA
if (cc_cp_speed == 0) { // 0:low 1:normal 2:high
divisionRate = 100;
} else if (cc_cp_speed == 1) {
divisionRate = 10;
} else {
divisionRate = 1;
}
} else {
if (cc_cp_speed == 0) { // 0:low 1:normal 2:high
divisionRate = 100;
} else if (cc_cp_speed == 1) {
divisionRate = 20;
} else {
divisionRate = 20;
}
}
if (!vscanReset) {
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
deltaI = Iin - i_set;
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
if (deltaI > 400000 || deltaI < -400000) { //20uA
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
cc_cp_speed = 100;
} else if (instru.cc_cp_speed == 1) {
cc_cp_speed = 10;
} else {
cc_cp_speed = 1;
}
} else {
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
cc_cp_speed = 100;
} else if (instru.cc_cp_speed == 1) {
cc_cp_speed = 20;
} else {
cc_cp_speed = 20;
}
}
if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
deltaV = DELTAVOLTMAX;
} else if (deltaV < (-DELTAVOLTMAX)) {
deltaV = (-DELTAVOLTMAX);
}
divisionRate = cc_cp_speed;
Vset = Vset + deltaV; //[5nV]
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
if (Vset >= 1100000000) { // 5.5V
Vset = 1100000000;
} else if (Vset <= -1000000000) { //-5V
Vset = -1000000000;
}
if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
deltaV = DELTAVOLTMAX;
} else if (deltaV < (-DELTAVOLTMAX)) {
deltaV = (-DELTAVOLTMAX);
}
Vset = Vset + deltaV; //[5nV]
if (Vset >= 1100000000) { // 5.5V
Vset = 1100000000;
} else if (Vset <= -1000000000) { //-5V
Vset = -1000000000;
}
if (Vset <= cc->_Vmin) {
Vset = cc->_Vmin;
} else if (Vset >= cc->_Vmax) {
Vset = cc->_Vmax;
}
if (Vset <= cc->_Vmin) {
Vset = cc->_Vmin;
} else if (Vset >= cc->_Vmax) {
Vset = cc->_Vmax;
}
return;
@@ -296,20 +289,14 @@ static void cp_vscan(void)
static int32_t i_set = 0;
if (vscanReset) {
Vset = 0;
if (cp->_charge == 0) {
i_set = cp->_Iset * (-1);
} else if(cp->_charge == 1) {
i_set = cp->_Iset;
}
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
Voutin = m->_measureVout * 200; //[5nV]
// if (cc_resistance == 1) //vout has 100R
// Vset = Voutin + (i_set * RESISTANCE_100R); //[5nV]
// else
Vset = Voutin; //[5nV]
if (Vset >= 1100000000) { // 5.5V
@@ -317,53 +304,45 @@ static void cp_vscan(void)
} else if (Vset <= -1000000000) { //-5V
Vset = -1000000000;
}
return;
}
if (!vscanReset) {
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
deltaI = Iin - i_set;
Iin = m->_measureCurrent * 20; //[50pA] nA => 50pA
deltaI = Iin - i_set;
if (deltaI > 400000 || deltaI < -400000) { //20uA
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
cc_cp_speed = 100;
} else if (instru.cc_cp_speed == 1) {
cc_cp_speed = 10;
} else {
cc_cp_speed = 1;
}
if (deltaI > 400000 || deltaI < -400000) { //20uA
if (cc_cp_speed == 0) { // 0:low 1:normal 2:high
divisionRate = 100;
} else if (cc_cp_speed == 1) {
divisionRate = 10;
} else {
if (instru.cc_cp_speed == 0) { // 0:low 1:normal 2:high
cc_cp_speed = 100;
} else if (instru.cc_cp_speed == 1) {
cc_cp_speed = 20;
} else {
cc_cp_speed = 20;
}
divisionRate = 1;
}
divisionRate = cc_cp_speed;
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
// if (deltaV > DELTAVOLTMAX) { //2000000 = 10mV
// deltaV = DELTAVOLTMAX;
// } else if (deltaV < (-DELTAVOLTMAX)) {
// deltaV = (-DELTAVOLTMAX);
// }
Vset = Vset + deltaV; //[5nV]
if (Vset >= 1100000000) { // 5.5V
Vset = 1100000000;
} else if (Vset <= -1000000000) { //-5V
Vset = -1000000000;
} else {
if (cc_cp_speed == 0) { // 0:low 1:normal 2:high
divisionRate = 100;
} else if (cc_cp_speed == 1) {
divisionRate = 20;
} else {
divisionRate = 20;
}
}
if (Vset <= cp->_Vmin) {
Vset = cp->_Vmin;
} else if (Vset >= cp->_Vmax) {
Vset = cp->_Vmax;
}
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
Vset = Vset + deltaV; //[5nV]
if (Vset >= 1100000000) { // 5.5V
Vset = 1100000000;
} else if (Vset <= -1000000000) { //-5V
Vset = -1000000000;
}
if (Vset <= cp->_Vmin) {
Vset = cp->_Vmin;
} else if (Vset >= cp->_Vmax) {
Vset = cp->_Vmax;
}
return;