fix CV3 cycle

This commit is contained in:
Roy
2020-05-21 21:45:32 +08:00
parent 889a3d4147
commit 5a7980dca5
5 changed files with 58 additions and 72 deletions
@@ -175,6 +175,13 @@ static void CV3_Vscan(CV3Mode *CV3){
current_direction_up = false;
}
if(Vmin == Vinit){
VminCounter = -1;
}
if(Vmax == Vinit){
VmaxCounter = -1;
}
Vset = Vinit;
if(INSTRUCTION.Step <= 10){
Vstep = INSTRUCTION.Step * INSTRUCTION.VscanRate / 2 ; //Vsetp = x * 50 * N / 10, x=xmV ; N=VscanRate
@@ -185,8 +192,6 @@ static void CV3_Vscan(CV3Mode *CV3){
int32_t RealV;
RealV = (int32_t)(Vset / 500);//[1uV]
InputNotify(NOTIFY_VOLT, RealV);
VscanReset = false;
}
@@ -199,6 +204,11 @@ static void CV3_Vscan(CV3Mode *CV3){
VminCounter++;
}
if (current_direction_up){
Vset = Vset + Vstep;
}else{
Vset = Vset - Vstep;
}
if(VmaxCounter != 0 && VminCounter != 0){
if(VmaxCounter == VminCounter && direction_up && current_direction_up){
@@ -211,7 +221,7 @@ static void CV3_Vscan(CV3Mode *CV3){
}
if(VmaxCounter == VminCounter && !direction_up && !current_direction_up){
if(CycleCounter != VmaxCounter){
if(Vset >= Vinit){
if(Vset <= Vinit){
CV3->CycleNumber--;
CycleCounter = VmaxCounter; //VmaxCounter = VminCounter = CycleCounter
}
@@ -220,14 +230,6 @@ static void CV3_Vscan(CV3Mode *CV3){
}
if (current_direction_up){
Vset = Vset + Vstep;
}else{
Vset = Vset - Vstep;
}
// int32_t RealV;
// RealV = (int32_t)(Vset / 500);//[1uV]
// InputNotify(NOTIFY_IMPEDANCE, RealV);
@@ -646,7 +646,6 @@ static void CV_Vscan(CVMode *CV){
RealV = (int32_t)(Vset / 200);//[1uV]
InputNotify(NOTIFY_IMPEDANCE, RealV);
VscanReset = false;
}
@@ -222,7 +222,6 @@ static void IV_Vscan(IVMode *IV){
OneWayVoltScan(IV);
VscanReset = false;
}
@@ -5,8 +5,8 @@
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 5
#define VERSION_DATE_DAY 21
#define VERSION_DATE_HOUR 18
#define VERSION_DATE_MINUTE 1
#define VERSION_DATE_HOUR 21
#define VERSION_DATE_MINUTE 45
// this is NOT the version hash !!
// it's the last version hash
@@ -94,7 +94,6 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
*/
static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
if ( IsPeriodicMode() ){
static int32_t testcount;
/** Periodic Event **/
// Default working flow is DAC out -> ADC read -> send notify
// We will need a flag to control DAC, if we want to exchange to ADC -> DAC -> notify
@@ -103,14 +102,11 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
GPT.GptimerCounter0 = GPT.GptimerCounter;
//INSTRUCTION.NotifyRate = 500;
if(EliteWorkReset){
if(INSTRUCTION.eliteFxn == ZT_CURVE || INSTRUCTION.eliteFxn == VT_CURVE || INSTRUCTION.eliteFxn == IT_CURVE){
INSTRUCTION.NotifyRate = (uint32_t)INSTRUCTION.SampleRate;
}
InitEliteGPtimer();
testcount = 0;
EliteWorkReset = false;
}
@@ -118,75 +114,65 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
if(LeadTimeReset && GPT.LeadTimeCounter <= 2000){
VscanReset = true;
// testcount += 1;
// InputNotify(NOTIFY_IMPEDANCE, testcount);
}else{
if(firstNotifyFlag){
GPT.NotifyCounter = INSTRUCTION.NotifyRate - 20;
firstNotifyFlag = false;
}
VscanReset = false;
LeadTimeReset = false;
// InputNotify(NOTIFY_IMPEDANCE, testcount);
}
//DAC counter
// In IV, CV, and func-gen mode, DAC will output voltage
// else DAC do nothing.
GPT.StepTimeCounter = GPT.StepTimeCounter + GPT.DeltaGptimerCounter;
if(GPT.StepTimeCounter >= INSTRUCTION.StepTime){
GPT.StepTimeCounter -= INSTRUCTION.StepTime;
DAC_flag = true;
if(DAC_flag){
EliteDACControl(WorkModeData);
DAC_flag = false;
}
//DAC counter
// In IV, CV, and func-gen mode, DAC will output voltage
// else DAC do nothing.
GPT.StepTimeCounter = GPT.StepTimeCounter + GPT.DeltaGptimerCounter;
if(GPT.StepTimeCounter >= INSTRUCTION.StepTime){
GPT.StepTimeCounter -= INSTRUCTION.StepTime;
DAC_flag = true;
if(DAC_flag){
EliteDACControl(WorkModeData);
DAC_flag = false;
}
}
//Vscan counter
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
if(GPT.VscanRateCounter >= INSTRUCTION.VscanRate){
GPT.VscanRateCounter -= INSTRUCTION.VscanRate;
Vscan_flag = true;
if(Vscan_flag){
EliteVscanControl(WorkModeData);
Vscan_flag = false;
}
//Vscan counter
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
if(GPT.VscanRateCounter >= INSTRUCTION.VscanRate){
GPT.VscanRateCounter -= INSTRUCTION.VscanRate;
Vscan_flag = true;
if(Vscan_flag){
EliteVscanControl(WorkModeData);
Vscan_flag = false;
}
}
//ADC counter(Control ADC to sample rate)
GPT.SampleRate_counter = GPT.SampleRate_counter + GPT.DeltaGptimerCounter;
if(GPT.SampleRate_counter >= INSTRUCTION.SampleRate){
GPT.SampleRate_counter -= INSTRUCTION.SampleRate;
ADC_flag = true;
if(ADC_flag){
EliteADCControl(WorkModeData);
ADC_flag = false;
}
//ADC counter(Control ADC to sample rate)
GPT.SampleRate_counter = GPT.SampleRate_counter + GPT.DeltaGptimerCounter;
if(GPT.SampleRate_counter >= INSTRUCTION.SampleRate){
GPT.SampleRate_counter -= INSTRUCTION.SampleRate;
ADC_flag = true;
if(ADC_flag){
EliteADCControl(WorkModeData);
ADC_flag = false;
}
}
//Notify counter(Notify control, check if we need to send notify)
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
if(GPT.NotifyCounter >= INSTRUCTION.NotifyRate){
GPT.NotifyCounter -= INSTRUCTION.NotifyRate;
notify_flag = true;
if(VscanReset){
notify_flag = false;
}
if(notify_flag){
SendNotify();
notify_flag = false;
}
//Notify counter(Notify control, check if we need to send notify)
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
if(GPT.NotifyCounter >= INSTRUCTION.NotifyRate){
GPT.NotifyCounter -= INSTRUCTION.NotifyRate;
notify_flag = true;
if(VscanReset){
notify_flag = false;
}
if(notify_flag){
SendNotify();
notify_flag = false;
}
}
EliteDone();
EliteDone();
}
else if(INSTRUCTION.eliteFxn == VOLT_OUTPUT){