fix CC mode (not ok)

This commit is contained in:
YiChin
2020-06-22 11:10:32 +08:00
parent f2d404ed60
commit bc3106fc26
4 changed files with 33 additions and 16 deletions
@@ -143,6 +143,27 @@ static void CCCurrent2IUC(CCMode *CC){
}
static uint16_t CCCurve(CCMode *CC){
static uint16_t DACOutCode;
static int32_t Vout;
static int32_t DeltaVout;
if(DACReset){
Vout = Vset;
DACReset = false;
}else{
DeltaVout = Vset - (Vout);
Vout = Vout + DeltaVout;
}
INSTRUCTION.VoltConstant = Vout / 40000 + 25000; //5nV=>usercode
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant);
DAC_outputV(DACOutCode);
return DACOutCode;
}
static void CC_Plot(CCMode *CC){
/**********************************************
CURRENT_MODE->_VoVi_Switch : 1 read Vin volt
@@ -165,7 +186,7 @@ static void CC_Plot(CCMode *CC){
CC_Vscan(CC);
OneWayVoltScan();
CCCurve(CC);
// read Volt
if(INSTRUCTION.VoVi_Switch == 0x01){
@@ -259,10 +280,10 @@ static void CC_Vscan(CCMode *CC){
Iin = CC->_MeasureData * 20; //[50pA] nA => 50pA
deltaI = Iin - Iset;
deltaV = -1 * (deltaI / 1000); //-5 * deltaI / 5000 //pV=> 5nV
if(deltaV > DELTAVOLTMAX){
deltaV = DELTAVOLTMAX;
}else if(deltaV < (-1 * DELTAVOLTMAX)){
deltaV = (-1 * DELTAVOLTMAX);
if(deltaV > 100000){
deltaV = 100000;
}else if(deltaV < (-100000)){
deltaV = (-100000);
}
Vset = Vset + deltaV; //[5nV]
@@ -273,9 +294,9 @@ static void CC_Vscan(CCMode *CC){
}
}
// int32_t RealV;
// RealV = (int32_t)(Vset / 200);//[1uV]
// InputNotify(NOTIFY_IMPEDANCE, RealV);
int32_t RealV;
RealV = (int32_t)(deltaV);
InputNotify(NOTIFY_IMPEDANCE, RealV);
}
@@ -37,11 +37,6 @@ static uint16_t OneWayVoltScan() {
DACReset = false;
}else{
DeltaVout = Vset - (Vout);
if(DeltaVout > 100000){
DeltaVout = 100000;
}else if(DeltaVout < (-100000)){
DeltaVout = (-100000);
}
Vout = Vout + DeltaVout;
}
@@ -4,9 +4,9 @@
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 6
#define VERSION_DATE_DAY 20
#define VERSION_DATE_HOUR 16
#define VERSION_DATE_MINUTE 12
#define VERSION_DATE_DAY 22
#define VERSION_DATE_HOUR 11
#define VERSION_DATE_MINUTE 10
// this is NOT the version hash !!
// it's the last version hash
@@ -707,6 +707,7 @@ static void ramp_test();
static uint16_t DPVCurve(WorkMode *WorkModeData);
static uint16_t CVCurve(CVMode *CV);
static uint16_t SWVCurve(WorkMode *WorkModeData);
static uint16_t CCCurve(CCMode *CC);
static uint16_t CV3Curve(CV3Mode *CV3);
static uint16_t LSVCurve(LSVMode *LSV);
static uint16_t CVSCANCurve(CVSCANMode *CVSCAN);