Modify calibration functions.

This commit is contained in:
Benny Liu
2021-09-30 16:00:11 +08:00
parent 8b1ee78b63
commit 49f99fb9f6
5 changed files with 46 additions and 45 deletions
@@ -359,17 +359,17 @@ static void Cali_DAC_output () {
static int32_t LPvolt = 0;
if (instru.DAC_type == HSDACtype_DC) {
instru.AdcChannel = EIS_HSDAC;
instru.AdcChannel = EIS_DAC;
HS_cali_config();
HSDAC_output(instru.VAmpSet);
} else if (instru.DAC_type == EIS_LPDAC) {
instru.AdcChannel = EIS_LPDAC;
} else if (instru.DAC_type == LPDACtype_DC) {
instru.AdcChannel = EIS_DAC;
LP_cali_config();
LPvolt = (int32_t)(instru.VAmpSet);
LPvolt = (LPvolt - 25000) * 4 * 4000;
cali_DAC_outputV(LPvolt);
} else if (instru.DAC_type == HSDACtype_AC) {
instru.AdcChannel = EIS_HSDAC;
instru.AdcChannel = EIS_DAC;
HS_cali_config();
DAC_outputF(0x00000800);
SetWGAmp(instru.VAmpSet); // sine wave generation usage
@@ -101,14 +101,14 @@ struct HEADSTAGE_INSTRUCTION {
/** Iin, Vin, Vout **/
#define EIS_HSTIA 0x00
#define EIS_LPTIA 0x01
#define EIS_HSDAC 0x02
#define EIS_LPDAC 0x03
#define VOUT_DAC 0x04
#define IIN_ADC 0x05
#define VIN_ADC 0x06
#define HIGH_Z 0x07
#define EIS_DAC 0x02
#define VOUT_DAC 0x03
#define IIN_ADC 0x04
#define VIN_ADC 0x05
#define HIGH_Z 0x06
#define HSDACtype_DC 0x01
#define HSDACtype_DC 0x00
#define LPDACtype_DC 0x01
#define HSDACtype_AC 0x02
/** ADC Iin gain level **/
@@ -291,7 +291,7 @@ static void InitEliteInstruction(){
// EIS DAC
instru.VAmpSet = EIS_HSDAC_ZERO;
instru.DAC_type = EIS_HSDAC;
instru.DAC_type = HSDACtype_DC;
// EIS ADC
instru.HSTIAGainLv = 0;
@@ -180,14 +180,12 @@ static void WorkModeLED()
Elite_led_color(COLOR_ORANGE);
} else if (instru.AdcChannel == VOUT_DAC) {
Elite_led_color(COLOR_BLUE);
}else if (instru.AdcChannel == EIS_HSDAC) {
}else if (instru.AdcChannel == EIS_DAC) {
Elite_led_color(COLOR_PURPLE_DARK);
} else if (instru.AdcChannel == EIS_HSTIA) {
Elite_led_color(COLOR_WHITE);
} else if (instru.AdcChannel == EIS_LPTIA) {
Elite_led_color(COLOR_RED);
} else if (instru.AdcChannel == EIS_LPDAC) {
Elite_led_color(COLOR_BLUE);
}
break;
@@ -599,9 +599,9 @@ static void cali_IT_plot(void) {
uint8_t CIS_buf[9] = {0};
CIS_buf[0] = instru.chip_id;
CIS_buf[1] = (uint8_t) ((ADCValueAVG & 0xFF00) >> 8);
CIS_buf[2] = (uint8_t) (ADCValueAVG & 0x00FF);
CIS_buf[3] = 0x00;
CIS_buf[1] = (uint8_t) ((ADCValueAVG & 0xFF0000) >> 16);
CIS_buf[2] = (uint8_t) ((ADCValueAVG & 0x00FF00) >> 8);
CIS_buf[3] = (uint8_t) (ADCValueAVG & 0x0000FF);
CIS_buf[4] = instru.HSTIAGainLv;
SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, 9, CIS_buf);
@@ -1047,18 +1047,7 @@ static void update_ZM_instruction(uint8 *ins) {
}
break;
}
case EIS_HSDAC : {
if(ins[4] == 0x00) {
instru.DAC_type = HSDACtype_DC;
} else if (ins[4] == 0x01) {
instru.DAC_type = EIS_LPDAC;
} else if (ins[4] == 0x02) {
instru.DAC_type = HSDACtype_AC;
}
HSDAC_GainControl(0x00); // fix HSDAC gain at default
break;
}
case EIS_HSTIA : {
case EIS_HSTIA : { // 0x00
instru.HSTIAGainLv = ins[4];
if (instru.HSTIAGainLv != HSRTIA_GAIN_AUTO) {
instru.HSTIAAutoGainEnable = 0;
@@ -1070,7 +1059,7 @@ static void update_ZM_instruction(uint8 *ins) {
HSTIAGainCtrl(instru.HSTIAGainLv);
break;
}
case EIS_LPTIA : {
case EIS_LPTIA : { // 0x01
instru.LPTIAGainLv = ins[4];
if (instru.LPTIAGainLv != LPRTIA_GAIN_AUTO) {
instru.LPTIAAutoGainEnable = 0;
@@ -1082,6 +1071,17 @@ static void update_ZM_instruction(uint8 *ins) {
LPTIAGainCtrl(instru.LPTIAGainLv);
break;
}
case EIS_DAC : { // 0x02
if(ins[4] == 0x00) {
instru.DAC_type = HSDACtype_DC;
} else if (ins[4] == 0x01) {
instru.DAC_type = LPDACtype_DC;
} else if (ins[4] == 0x02) {
instru.DAC_type = HSDACtype_AC;
}
HSDAC_GainControl(0x00); // fix HSDAC gain at default
break;
}
default :{
break;
}
@@ -1100,7 +1100,7 @@ static void update_ZM_instruction(uint8 *ins) {
case CURVE_CALI_ADC: {
switch(ins[3]) {
case IIN_ADC : { // 0x05
case IIN_ADC : { // 0x04
instru.eliteFxn = CURVE_CALI_ADC;
instru.AdcChannel = IIN_ADC;
instru.notifyRate = 1000;
@@ -1109,7 +1109,7 @@ static void update_ZM_instruction(uint8 *ins) {
ModeLED(WORKING);
break;
}
case VIN_ADC : { // 0x06
case VIN_ADC : { // 0x05
instru.eliteFxn = CURVE_CALI_ADC;
instru.AdcChannel = VIN_ADC;
instru.notifyRate = 1000;
@@ -1118,7 +1118,7 @@ static void update_ZM_instruction(uint8 *ins) {
ModeLED(WORKING);
break;
}
case VOUT_DAC : { // 0x04
case VOUT_DAC : { // 0x03
instru.eliteFxn = CURVE_CALI_ADC;
instru.AdcChannel = VOUT_DAC;
instru.notifyRate = 1000;
@@ -1130,15 +1130,6 @@ static void update_ZM_instruction(uint8 *ins) {
ModeLED(WORKING);
break;
}
case EIS_HSDAC :{ // 0x02
instru.eliteFxn = CURVE_CALI_ADC;
instru.notifyRate = 1000;
instru.sampleRate = 15;
instru.VAmpSet = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
Cali_DAC_output();
ModeLED(WORKING);
break;
}
case EIS_HSTIA :{ // 0x00
instru.VAmpSet = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
instru.DAC_type = HSDACtype_DC;
@@ -1152,6 +1143,9 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case EIS_LPTIA :{ // 0x01
instru.VAmpSet = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
instru.DAC_type = LPDACtype_DC;
Cali_DAC_output(); // LPDAC output DC bias
instru.eliteFxn = CURVE_CALI_ADC;
instru.AdcChannel = EIS_LPTIA;
instru.notifyRate = 1000;
@@ -1161,6 +1155,15 @@ static void update_ZM_instruction(uint8 *ins) {
ModeLED(WORKING);
break;
}
case EIS_DAC :{ // 0x02
instru.eliteFxn = CURVE_CALI_ADC;
instru.notifyRate = 1000;
instru.sampleRate = 15;
instru.VAmpSet = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
Cali_DAC_output();
ModeLED(WORKING);
break;
}
default : {
break;
}
@@ -1451,8 +1454,8 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case cali_HSTIA_Iin: { // 0x65
// instru.VAmpSet = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
instru.VAmpSet = 0x0E00;
instru.VAmpSet = ((uint16_t)(ins[4]) << 8) | (uint16_t)(ins[5]);
// instru.VAmpSet = 0x0E00;
instru.DAC_type = HSDACtype_DC;
Cali_DAC_output(); // HSDAC output DC bias