test not ok(RT not ok)

This commit is contained in:
YiChin
2020-11-12 17:24:04 +08:00
parent 67275a7921
commit ef9a38d7fc
5 changed files with 124 additions and 84 deletions
@@ -139,6 +139,7 @@ static void PULSE_Vscan(PULSEMode *PULSE){
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
}
vscanReset = false;
}
@@ -173,6 +174,7 @@ static void PULSE_Vscan(PULSEMode *PULSE){
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
}
}
else if (PULSE->_loop > 0 && PULSE->_cycleNumber <= 0) {
@@ -196,16 +198,71 @@ static void PULSE_Vscan(PULSEMode *PULSE){
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant));
}
}
else if (PULSE->_loop <= 0) {
if (PULSE->_tflag == PULSE->_t5) {
PeriodicEvent = false;
ELITE15_SPI_CLOSE();
ModeLED(NO_EVENT);
}
}
InputNotify(NOTIFY_IMPEDANCE, PULSE->_vflag);
}
}
static void test_Vscan(PULSEMode *PULSE){
if(GPT.VscanRateCounter >= 50000){
GPT.VscanRateCounter -= 50000;
vscan_flag = true;
if(vscan_flag){
static uint8_t testV = 0;
static uint16_t lastVolt = 0;
if(testV == 0){
testV++;
INSTRUCTION.VoltConstant = 25000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}else if(testV == 1){
testV++;
INSTRUCTION.VoltConstant = 30000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}else if(testV == 2){
testV++;
INSTRUCTION.VoltConstant = 35000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}else if(testV == 3){
testV++;
INSTRUCTION.VoltConstant = 40000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}else if(testV == 4){
testV = 0;
INSTRUCTION.VoltConstant = 35000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}
InputNotify(NOTIFY_IMPEDANCE, INSTRUCTION.VoltConstant);
vscan_flag = false;
}
}
}
#endif
@@ -8,7 +8,6 @@ static void reset() {
InitFlag();
InitCT();
InitGPT();
// InitLH();
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 0 => open high_z mode
@@ -46,13 +45,9 @@ static void Eliteinterrupt() {
InitEliteFlag();
InitCT();
InitGPT();
// InitLH();
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 0 => open high_z mode
VinADCGainControl(VIN_GAIN_AUTO);
IinADCGainControl(I_GAIN_AUTO);
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
@@ -75,8 +70,6 @@ static void Eliteinterrupt() {
spi_ADC_rxbuf[i] = 0;
}
// PIN15_setOutputValue(ADC_CS, 1); // ADC_CS HIGH
// PIN15_setOutputValue(DAC_CS, 1); // DAC_CS HIGH
CPUdelay(8000);
}
#endif
@@ -362,11 +362,11 @@ PULSEMode * InitPULSEMode(){
ret->_t3 = INSTRUCTION.t3;
ret->_t4 = INSTRUCTION.t4;
ret->_t5 = INSTRUCTION.t5;
ret->_v1 = (INSTRUCTION.v1 - 25000) * 4 * 10000; //[5nV]
ret->_v2 = (INSTRUCTION.v2 - 25000) * 4 * 10000; //[5nV];
ret->_v3 = (INSTRUCTION.v3 - 25000) * 4 * 10000; //[5nV];
ret->_v4 = (INSTRUCTION.v4 - 25000) * 4 * 10000; //[5nV];
ret->_v5 = (INSTRUCTION.v5 - 25000) * 4 * 10000; //[5nV];
ret->_v1 = INSTRUCTION.v1;
ret->_v2 = INSTRUCTION.v2;
ret->_v3 = INSTRUCTION.v3;
ret->_v4 = INSTRUCTION.v4;
ret->_v5 = INSTRUCTION.v5;
ret->_tflag = 0;
ret->_vflag = 0;
ret->_cycleNumber = INSTRUCTION.cycleNumber;
@@ -603,6 +603,7 @@ static uint16_t CV3Curve(CV3Mode *CV3);
static uint16_t LSVCurve(LSVMode *LSV);
static uint16_t CVSCANCurve(CVSCANMode *CVSCAN);
static void PULSE_Vscan(PULSEMode *PULSE);
static void test_Vscan(PULSEMode *PULSE);
//mode (notify)
static void initDATBuf();
@@ -678,10 +679,8 @@ static void update_ZM_instruction(uint8 *ins) {
if(INSTRUCTION.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.Ve2 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
}else{
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
}
break;
}
@@ -708,10 +707,8 @@ static void update_ZM_instruction(uint8 *ins) {
if(INSTRUCTION.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.Ve2 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
}else{
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
}
break;
}
@@ -724,10 +721,8 @@ static void update_ZM_instruction(uint8 *ins) {
if(INSTRUCTION.VoltConstant < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
}else{
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
}
break;
}
@@ -746,10 +741,8 @@ static void update_ZM_instruction(uint8 *ins) {
if(INSTRUCTION.VoltConstant < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
}else{
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
}
break;
}
@@ -785,7 +778,6 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
/*******************************************************
controller instruction
ins[3] -> Charge, 0:discharge 1:charge
@@ -822,7 +814,6 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.cycleNumber = ins[14];
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
}
break;
}
@@ -853,7 +844,6 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.cycleNumber = ins[19] * 100;
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
break;
}
@@ -879,7 +869,6 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.cycleNumber = 1;//ins[17];
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
break;
}
@@ -895,7 +884,6 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.VoViSwitch = 0x01;
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
break;
}
@@ -1178,16 +1166,15 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.t4 = 50000;
INSTRUCTION.t5 = 50000;
INSTRUCTION.v1 = 25000;
INSTRUCTION.v2 = 35000;
INSTRUCTION.v3 = 25000;
INSTRUCTION.v4 = 35000;
INSTRUCTION.v2 = 30000;
INSTRUCTION.v3 = 35000;
INSTRUCTION.v4 = 30000;
INSTRUCTION.v5 = 25000;
INSTRUCTION.cycleNumber = 2;
INSTRUCTION.loop = 2;
INSTRUCTION.VsetRate = 2;
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
VoutGainControl(INSTRUCTION.VoutGainLevel);
break;
}
@@ -200,7 +200,8 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
}
// EliteDone();
}else if (INSTRUCTION.eliteFxn == PULSE_MODE){
}
else if (INSTRUCTION.eliteFxn == PULSE_MODE){
/** Periodic Event **/
// Default working flow is vscan -> ADC read -> send notify
// We will need a flag to control vscan, ADC and notify
@@ -241,58 +242,59 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
//vscan counter
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
if(GPT.VscanRateCounter >= 50000){
GPT.VscanRateCounter -= 50000;
vscan_flag = true;
if(vscan_flag){
static uint8_t testV = 0;
static uint16_t lastVolt = 0;
if(testV == 0){
testV++;
INSTRUCTION.VoltConstant = 25000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}else if(testV == 1){
testV++;
INSTRUCTION.VoltConstant = 30000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}else if(testV == 2){
testV++;
INSTRUCTION.VoltConstant = 35000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}else if(testV == 3){
testV++;
INSTRUCTION.VoltConstant = 40000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}else if(testV == 4){
testV = 0;
INSTRUCTION.VoltConstant = 35000;
if(lastVolt != INSTRUCTION.VoltConstant){
lastVolt = INSTRUCTION.VoltConstant;
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
}
}
InputNotify(NOTIFY_IMPEDANCE, INSTRUCTION.VoltConstant);
vscan_flag = false;
}
}
test_Vscan(WorkModeData->PULSE);
// if(GPT.VscanRateCounter >= 50000){
// GPT.VscanRateCounter -= 50000;
//
// vscan_flag = true;
// if(vscan_flag){
// static uint8_t testV = 0;
// static uint16_t lastVolt = 0;
// if(testV == 0){
// testV++;
// INSTRUCTION.VoltConstant = 25000;
// if(lastVolt != INSTRUCTION.VoltConstant){
// lastVolt = INSTRUCTION.VoltConstant;
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// }
// }else if(testV == 1){
// testV++;
// INSTRUCTION.VoltConstant = 30000;
// if(lastVolt != INSTRUCTION.VoltConstant){
// lastVolt = INSTRUCTION.VoltConstant;
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// }
// }else if(testV == 2){
// testV++;
// INSTRUCTION.VoltConstant = 35000;
// if(lastVolt != INSTRUCTION.VoltConstant){
// lastVolt = INSTRUCTION.VoltConstant;
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// }
// }else if(testV == 3){
// testV++;
// INSTRUCTION.VoltConstant = 40000;
// if(lastVolt != INSTRUCTION.VoltConstant){
// lastVolt = INSTRUCTION.VoltConstant;
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// }
// }else if(testV == 4){
// testV = 0;
// INSTRUCTION.VoltConstant = 35000;
// if(lastVolt != INSTRUCTION.VoltConstant){
// lastVolt = INSTRUCTION.VoltConstant;
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, INSTRUCTION.VoltConstant));
// }
// }
// InputNotify(NOTIFY_IMPEDANCE, INSTRUCTION.VoltConstant);
// vscan_flag = false;
// }
// }
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate){
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate * 2){
// GPT.GptimerMultiple = GPT.VscanRateCounter / INSTRUCTION.VsetRate;
@@ -353,7 +355,8 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, WorkModeData->VO->_Vset)); //UserCode -> DAC code -> DAC out
FreeWorkMode(WorkModeData);
PeriodicEvent = false;
}else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
}
else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
FreeWorkMode(WorkModeData);
PeriodicEvent = false;