Merge branch 'Elite1.5_dev_module_0125_3' into Elite1.5_dev_module_0125_4

This commit is contained in:
Roy
2021-01-26 10:53:44 +08:00
16 changed files with 1639 additions and 1511 deletions
@@ -11,88 +11,92 @@
* Real current value : -15.00000 ~ 15.00000 mA
* => user code = 1500000 mapping to 0.00000 mA
*/
static void CC_Vscan(void *WM){
struct CCMode *CC = (struct CCMode *)WM;
static int32_t Iin = 0;
static int32_t deltaI = 0;
static int32_t deltaV = 0;
uint16_t divisionRate;
if(vscanReset){
Vset = 0;
if(CC->_charge == 0){
CC->_Iset = INSTRUCTION.constantCurrent * 200 * (-1); //[50pA] //controller UI 15000uA => Elite 1500000 => 1500000 * 10 * 1000 / 50 [50pA];
}
Iin = CC->_measureCurrent * 20; //[50pA] nA => 50pA
deltaI = Iin - CC->_Iset;
if(deltaI > 20000000 || deltaI < -20000000){ //1mA
divisionRate = 1000;
}else{
divisionRate = 10;
}
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
if(deltaV > DELTAVOLTMAX){ //100000 = 500uV
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(!vscanReset){
Iin = CC->_measureCurrent * 20; //[50pA] nA => 50pA
deltaI = Iin - CC->_Iset;
if(deltaI > 20000000 || deltaI < -20000000){ //1mA
divisionRate = 1000;
}else{
divisionRate = 10;
}
deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
if(deltaV > DELTAVOLTMAX){ //100000 = 500uV
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;
}
}
// int32_t RealV;
// RealV = (int32_t)(deltaV);
// InputNotify(NOTIFY_IMPEDANCE, RealV);
}
//static void CC_Vscan(void){
//// struct CCMode *CC = (struct CCMode *)WM;
//
//// struct instr_ctx_t *instr = instr_ctx;
// struct wm_vt_ctx_t *CC = (struct CCMode *)wm_get();
// struct wm_meas_t *m = &CC->measure;
//
// static int32_t Iin = 0;
// static int32_t deltaI = 0;
// static int32_t deltaV = 0;
// uint16_t divisionRate;
//
// if(vscanReset){
// Vset = 0;
//
// if(CC->_charge == 0){
// CC->_Iset = INSTRUCTION.constantCurrent * 200 * (-1); //[50pA] //controller UI 15000uA => Elite 1500000 => 1500000 * 10 * 1000 / 50 [50pA];
// }
//
// Iin = CC->_measureCurrent * 20; //[50pA] nA => 50pA
// deltaI = Iin - CC->_Iset;
//
// if(deltaI > 20000000 || deltaI < -20000000){ //1mA
// divisionRate = 1000;
// }else{
// divisionRate = 10;
// }
//
// deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
//
// if(deltaV > DELTAVOLTMAX){ //100000 = 500uV
// 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(!vscanReset){
// Iin = CC->_measureCurrent * 20; //[50pA] nA => 50pA
// deltaI = Iin - CC->_Iset;
//
// if(deltaI > 20000000 || deltaI < -20000000){ //1mA
// divisionRate = 1000;
// }else{
// divisionRate = 10;
// }
//
// deltaV = -1 * (deltaI / divisionRate); //-5 * deltaI / 5000 //pV=> 5nV
//
// if(deltaV > DELTAVOLTMAX){ //100000 = 500uV
// 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;
// }
// }
//// int32_t RealV;
//// RealV = (int32_t)(deltaV);
//// InputNotify(NOTIFY_IMPEDANCE, RealV);
//}
#endif
@@ -2,155 +2,155 @@
#define ELITECV3
#define Vset INSTRUCTION.Vset
static uint16_t CV3Curve(void *WM){
struct CV3Mode *CV3 = (struct CV3Mode *)WM;
static uint16_t DACOutCode;
static int32_t Vin;
static int32_t Vout;
static int32_t DeltaVout;
Vin = CV3->_measureVin * 200;//[5nV]
if(DACReset){
Vout = Vset + Vin;
DACReset = false;
}else{
DeltaVout = Vset - (Vout - Vin);
Vout = Vout + DeltaVout;
}
INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant);
int32_t RealV2;
RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
InputNotify(NOTIFY_VOLT, RealV2);
int32_t RealV;
RealV = (int32_t)(Vout / 200);//[1uV]
InputNotify(NOTIFY_IMPEDANCE, RealV);
DAC_outputV(DACOutCode);
return DACOutCode;
}
static void CV3_Vscan(void *WM){
struct CV3Mode *CV3 = (struct CV3Mode *)WM;
static bool VminCounter;
static bool VmaxCounter;
NotifyCycleNumber = (INSTRUCTION.cycleNumber - CV3->_cycleNumber + 1);
if (vscanReset) {
VmaxCounter = false;
VminCounter = false;
if (INSTRUCTION.directionInit == 1) {
CV3->_direction_up = true;
CV3->_current_direction_up = true;
} else {
CV3->_direction_up = false;
CV3->_current_direction_up = false;
}
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
if (INSTRUCTION.step <= 10) {
CV3->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
} else {
CV3->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
}
if (CV3->_Vmin == CV3->_Vinit) {
VminCounter = true;
}
if (CV3->_Vmax == CV3->_Vinit) {
VmaxCounter = true;
}
Vset = CV3->_Vinit;
}
if (!vscanReset) {
if ((INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) ||
(INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2)
) {
if (CV3->_current_direction_up) {
Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
} else {
Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
}
if (INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) {
if (Vset == CV3->_Vmin) {
VminCounter = true;
INSTRUCTION.Vinit = INSTRUCTION.Vmin;
CV3->_Vinit = CV3->_Vmin;
}
} else if (INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2) {
if (Vset == CV3->_Vmax) {
VmaxCounter = true;
INSTRUCTION.Vinit = INSTRUCTION.Vmax;
CV3->_Vinit = CV3->_Vmax;
}
}
} else {
if (Vset >= CV3->_Vmax) {
VmaxCounter = true;
} else if (Vset <= CV3->_Vmin) {
VminCounter = true;
}
if (CV3->_current_direction_up) {
Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
} else {
Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
}
if (VmaxCounter && VminCounter) {
if (CV3->_direction_up && CV3->_current_direction_up) {
if (Vset >= CV3->_Vinit) {
CV3->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
if (!CV3->_direction_up && !CV3->_current_direction_up) {
if (Vset <= CV3->_Vinit) {
CV3->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
}
if (Vset >= CV3->_Vmax) {
CV3->_current_direction_up = false;
} else if (Vset <= CV3->_Vmin) {
CV3->_current_direction_up = true;
}
/*stop condition*/
if (CV3->_cycleNumber == 0) {
// PeriodicEvent = false;
ModeLED(POST_WORK);
InitEliteFlag();
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.charge = 0x01;
INSTRUCTION.constantCurrent = 0x00;
INSTRUCTION.Vmax = 0xC350;
INSTRUCTION.Vmin = 0x0000;
INSTRUCTION.notifyRate = 500;
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
}
}
}
//
//static uint16_t CV3Curve(void *WM){
// struct CV3Mode *CV3 = (struct CV3Mode *)WM;
//
// static uint16_t DACOutCode;
// static int32_t Vin;
// static int32_t Vout;
// static int32_t DeltaVout;
//
// Vin = CV3->_measureVin * 200;//[5nV]
// if(DACReset){
// Vout = Vset + Vin;
// DACReset = false;
// }else{
// DeltaVout = Vset - (Vout - Vin);
// Vout = Vout + DeltaVout;
// }
//
// INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
// DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant);
//
// int32_t RealV2;
// RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
// InputNotify(NOTIFY_VOLT, RealV2);
//
// int32_t RealV;
// RealV = (int32_t)(Vset / 500);//[1uV]
// InputNotify(NOTIFY_VOLT, RealV);
}
// RealV = (int32_t)(Vout / 200);//[1uV]
// InputNotify(NOTIFY_IMPEDANCE, RealV);
//
// DAC_outputV(DACOutCode);
//
// return DACOutCode;
//}
//
//
//static void CV3_Vscan(void *WM){
// struct CV3Mode *CV3 = (struct CV3Mode *)WM;
//
// static bool VminCounter;
// static bool VmaxCounter;
//
// NotifyCycleNumber = (INSTRUCTION.cycleNumber - CV3->_cycleNumber + 1);
//
// if (vscanReset) {
// VmaxCounter = false;
// VminCounter = false;
//
// if (INSTRUCTION.directionInit == 1) {
// CV3->_direction_up = true;
// CV3->_current_direction_up = true;
// } else {
// CV3->_direction_up = false;
// CV3->_current_direction_up = false;
// }
//
// //Vsetp = x * 20 * N, x=xmV ; N=VscanRate
// if (INSTRUCTION.step <= 10) {
// CV3->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
// } else {
// CV3->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
// }
//
// if (CV3->_Vmin == CV3->_Vinit) {
// VminCounter = true;
// }
// if (CV3->_Vmax == CV3->_Vinit) {
// VmaxCounter = true;
// }
//
// Vset = CV3->_Vinit;
// }
//
// if (!vscanReset) {
// if ((INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) ||
// (INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2)
// ) {
// if (CV3->_current_direction_up) {
// Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
// } else {
// Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
// }
//
// if (INSTRUCTION.Vinit < INSTRUCTION.Ve1 && INSTRUCTION.Vinit < INSTRUCTION.Ve2) {
// if (Vset == CV3->_Vmin) {
// VminCounter = true;
// INSTRUCTION.Vinit = INSTRUCTION.Vmin;
// CV3->_Vinit = CV3->_Vmin;
// }
// } else if (INSTRUCTION.Vinit > INSTRUCTION.Ve1 && INSTRUCTION.Vinit > INSTRUCTION.Ve2) {
// if (Vset == CV3->_Vmax) {
// VmaxCounter = true;
// INSTRUCTION.Vinit = INSTRUCTION.Vmax;
// CV3->_Vinit = CV3->_Vmax;
// }
// }
// } else {
// if (Vset >= CV3->_Vmax) {
// VmaxCounter = true;
// } else if (Vset <= CV3->_Vmin) {
// VminCounter = true;
// }
//
// if (CV3->_current_direction_up) {
// Vset = Vset + CV3->_Vstep * GPT.GptimerMultiple;
// } else {
// Vset = Vset - CV3->_Vstep * GPT.GptimerMultiple;
// }
//
// if (VmaxCounter && VminCounter) {
// if (CV3->_direction_up && CV3->_current_direction_up) {
// if (Vset >= CV3->_Vinit) {
// CV3->_cycleNumber--;
// VminCounter = false;
// VmaxCounter = false;
// }
// }
// if (!CV3->_direction_up && !CV3->_current_direction_up) {
// if (Vset <= CV3->_Vinit) {
// CV3->_cycleNumber--;
// VminCounter = false;
// VmaxCounter = false;
// }
// }
// }
//
// if (Vset >= CV3->_Vmax) {
// CV3->_current_direction_up = false;
// } else if (Vset <= CV3->_Vmin) {
// CV3->_current_direction_up = true;
// }
//
// /*stop condition*/
// if (CV3->_cycleNumber == 0) {
// // PeriodicEvent = false;
// ModeLED(POST_WORK);
// InitEliteFlag();
// INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
// INSTRUCTION.sampleRate = 15;
// INSTRUCTION.charge = 0x01;
// INSTRUCTION.constantCurrent = 0x00;
// INSTRUCTION.Vmax = 0xC350;
// INSTRUCTION.Vmin = 0x0000;
// INSTRUCTION.notifyRate = 500;
// INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
// }
// }
// }
//// int32_t RealV;
//// RealV = (int32_t)(Vset / 500);//[1uV]
//// InputNotify(NOTIFY_VOLT, RealV);
//}
#endif
@@ -2,214 +2,214 @@
#ifndef ELITECV
#define ELITECV
static uint16_t SWVCurve(void *WorkModeData) {
static uint8_t counter;
static uint16_t outputV;
static uint16_t Volt;
static bool direction_up;
//static uint16_t SWVCurve(void *WorkModeData) {
// static uint8_t counter;
// static uint16_t outputV;
// static uint16_t Volt;
// static bool direction_up;
//
// // reset origin volt at the begin
// if (DACReset) {
// Volt = INSTRUCTION.Ve1;
// outputV = INSTRUCTION.Ve1;
// if (INSTRUCTION.Ve1 < INSTRUCTION.Ve2)
// direction_up = true;
// else
// direction_up = false;
// counter = 1;
// DACReset = false;
// }
//
// if (counter == 2 * PulseWidth)
// counter = 1;
// else
// counter++;
//
// // output a certain volt
// outputV = Volt;
// DAC_outputV(outputV);
//
// // VoltValue = (ramp1*16 + ramp0/16) * 3.05;
//
// // check if we reach the final volt
// if ((outputV >= INSTRUCTION.Ve2 && direction_up) || (outputV <= INSTRUCTION.Ve2 && !direction_up)) {
// PeriodicEvent = false;
// DACReset = true;
// }
//
// // prepare the next output volt
// if (direction_up) {
// if (counter == PulseWidth)
// Volt = Volt + Amplitude;
// else if (counter == 2 * PulseWidth)
// Volt = Volt - (Amplitude - INSTRUCTION.step);
// else
// Volt = Volt;
// } else {
// if (counter == PulseWidth)
// Volt = Volt - Amplitude;
// else if (counter == 2 * PulseWidth)
// Volt = Volt + (Amplitude - INSTRUCTION.step);
// else
// Volt = Volt;
// }
//
// return outputV;
//}
//
//static uint16_t DPVCurve(void *WorkModeData) {
// static uint8_t counter;
// static uint16_t Volt1;
// static uint16_t Volt2;
// static uint16_t outputV;
// static bool direction_up;
//
// // reset origin volt at the begin
// if (DACReset) {
// if (INSTRUCTION.Ve1 < INSTRUCTION.Ve2)
// direction_up = true;
// else
// direction_up = false;
//
// Volt1 = INSTRUCTION.Ve1;
// if (direction_up)
// Volt2 = INSTRUCTION.Ve1 + Amplitude;
// else
// Volt2 = INSTRUCTION.Ve1 - Amplitude;
//
// counter = 1;
// DACReset = false;
// }
//
// if (counter == PulsePeriod)
// counter = 1;
// else
// counter++;
//
// // output a certain volt
// if (counter <= (PulsePeriod - PulseWidth)) {
// outputV = Volt1;
// DAC_outputV(Volt1);
// } else {
// outputV = Volt2;
// DAC_outputV(Volt2);
// }
//
//
// // VoltValue = (ramp1*16 + ramp0/16) * 3.05;
//
// // check if we reach the final volt
// if (((outputV >= INSTRUCTION.Ve2) && direction_up) || ((outputV <= INSTRUCTION.Ve2) && !direction_up)) {
// PeriodicEvent = false;
// DACReset = true;
// }
//
// // check overflow/underflow and prepare for next output
// if (direction_up) {
// if (Volt1 + INSTRUCTION.step < Volt1)
// Volt1 = 0xffff;
// else
// Volt1 = Volt1 + INSTRUCTION.step;
// if (Volt2 + INSTRUCTION.step < Volt2)
// Volt2 = 0xffff;
// else
// Volt2 = Volt2 + INSTRUCTION.step;
// } else {
// if (Volt1 - INSTRUCTION.step > Volt1)
// Volt1 = 0x0000;
// else
// Volt1 = Volt1 - INSTRUCTION.step;
// if (Volt2 - INSTRUCTION.step > Volt2)
// Volt2 = 0x0000;
// else
// Volt2 = Volt2 - INSTRUCTION.step;
// }
//
// if (counter + 1 <= (PulsePeriod - PulseWidth)) {
// return Volt1;
// } else {
// return Volt2;
// }
//}
// reset origin volt at the begin
if (DACReset) {
Volt = INSTRUCTION.Ve1;
outputV = INSTRUCTION.Ve1;
if (INSTRUCTION.Ve1 < INSTRUCTION.Ve2)
direction_up = true;
else
direction_up = false;
counter = 1;
DACReset = false;
}
if (counter == 2 * PulseWidth)
counter = 1;
else
counter++;
// output a certain volt
outputV = Volt;
DAC_outputV(outputV);
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
// check if we reach the final volt
if ((outputV >= INSTRUCTION.Ve2 && direction_up) || (outputV <= INSTRUCTION.Ve2 && !direction_up)) {
PeriodicEvent = false;
DACReset = true;
}
// prepare the next output volt
if (direction_up) {
if (counter == PulseWidth)
Volt = Volt + Amplitude;
else if (counter == 2 * PulseWidth)
Volt = Volt - (Amplitude - INSTRUCTION.step);
else
Volt = Volt;
} else {
if (counter == PulseWidth)
Volt = Volt - Amplitude;
else if (counter == 2 * PulseWidth)
Volt = Volt + (Amplitude - INSTRUCTION.step);
else
Volt = Volt;
}
return outputV;
}
static uint16_t DPVCurve(void *WorkModeData) {
static uint8_t counter;
static uint16_t Volt1;
static uint16_t Volt2;
static uint16_t outputV;
static bool direction_up;
// reset origin volt at the begin
if (DACReset) {
if (INSTRUCTION.Ve1 < INSTRUCTION.Ve2)
direction_up = true;
else
direction_up = false;
Volt1 = INSTRUCTION.Ve1;
if (direction_up)
Volt2 = INSTRUCTION.Ve1 + Amplitude;
else
Volt2 = INSTRUCTION.Ve1 - Amplitude;
counter = 1;
DACReset = false;
}
if (counter == PulsePeriod)
counter = 1;
else
counter++;
// output a certain volt
if (counter <= (PulsePeriod - PulseWidth)) {
outputV = Volt1;
DAC_outputV(Volt1);
} else {
outputV = Volt2;
DAC_outputV(Volt2);
}
// VoltValue = (ramp1*16 + ramp0/16) * 3.05;
// check if we reach the final volt
if (((outputV >= INSTRUCTION.Ve2) && direction_up) || ((outputV <= INSTRUCTION.Ve2) && !direction_up)) {
PeriodicEvent = false;
DACReset = true;
}
// check overflow/underflow and prepare for next output
if (direction_up) {
if (Volt1 + INSTRUCTION.step < Volt1)
Volt1 = 0xffff;
else
Volt1 = Volt1 + INSTRUCTION.step;
if (Volt2 + INSTRUCTION.step < Volt2)
Volt2 = 0xffff;
else
Volt2 = Volt2 + INSTRUCTION.step;
} else {
if (Volt1 - INSTRUCTION.step > Volt1)
Volt1 = 0x0000;
else
Volt1 = Volt1 - INSTRUCTION.step;
if (Volt2 - INSTRUCTION.step > Volt2)
Volt2 = 0x0000;
else
Volt2 = Volt2 - INSTRUCTION.step;
}
if (counter + 1 <= (PulsePeriod - PulseWidth)) {
return Volt1;
} else {
return Volt2;
}
}
static void CV_Vscan(void *WM){
struct CVMode *CV = (struct CVMode *)WM;
static bool VminCounter;
static bool VmaxCounter;
NotifyCycleNumber = (INSTRUCTION.cycleNumber - CV->_cycleNumber + 1);
if(vscanReset){
VmaxCounter = false;
VminCounter = false;
if(INSTRUCTION.directionInit == 1){
CV->_direction_up = true;
CV->_current_direction_up = true;
}else if(INSTRUCTION.directionInit == 0){
CV->_direction_up = false;
CV->_current_direction_up = false;
}
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
if(INSTRUCTION.step <= 10){
CV->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
}else{
CV->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
}
if(CV->_Vmin == CV->_Vinit){
VminCounter = true;
}
if(CV->_Vmax == CV->_Vinit){
VmaxCounter = true;
}
Vset = CV->_Vinit;
}
if(!vscanReset){
if (Vset >= CV->_Vmax){
VmaxCounter = true;
}else if (Vset <= CV->_Vmin){
VminCounter = true;
}
if (CV->_current_direction_up){
Vset = Vset + CV->_Vstep * GPT.GptimerMultiple;
}else{
Vset = Vset - CV->_Vstep * GPT.GptimerMultiple;
}
if(VmaxCounter && VminCounter){
if(CV->_direction_up && CV->_current_direction_up){
if(Vset >= CV->_Vinit){
CV->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
if(!CV->_direction_up && !CV->_current_direction_up){
if(Vset <= CV->_Vinit){
CV->_cycleNumber--;
VminCounter = false;
VmaxCounter = false;
}
}
}
if (Vset >= CV->_Vmax){
CV->_current_direction_up = false;
}else if (Vset <= CV->_Vmin){
CV->_current_direction_up = true;
}
/*stop condition*/
if(CV->_cycleNumber == 0){
PeriodicEvent = false;
ModeLED(NO_EVENT);
}
}
}
//static void CV_Vscan(void *WM){
// struct CVMode *CV = (struct CVMode *)WM;
//
// static bool VminCounter;
// static bool VmaxCounter;
//
// NotifyCycleNumber = (INSTRUCTION.cycleNumber - CV->_cycleNumber + 1);
//
// if(vscanReset){
// VmaxCounter = false;
// VminCounter = false;
//
// if(INSTRUCTION.directionInit == 1){
// CV->_direction_up = true;
// CV->_current_direction_up = true;
// }else if(INSTRUCTION.directionInit == 0){
// CV->_direction_up = false;
// CV->_current_direction_up = false;
// }
//
// //Vsetp = x * 20 * N, x=xmV ; N=VscanRate
// if(INSTRUCTION.step <= 10){
// CV->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
// }else{
// CV->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
// }
//
// if(CV->_Vmin == CV->_Vinit){
// VminCounter = true;
// }
// if(CV->_Vmax == CV->_Vinit){
// VmaxCounter = true;
// }
//
// Vset = CV->_Vinit;
// }
//
// if(!vscanReset){
// if (Vset >= CV->_Vmax){
// VmaxCounter = true;
// }else if (Vset <= CV->_Vmin){
// VminCounter = true;
// }
//
// if (CV->_current_direction_up){
// Vset = Vset + CV->_Vstep * GPT.GptimerMultiple;
// }else{
// Vset = Vset - CV->_Vstep * GPT.GptimerMultiple;
// }
//
// if(VmaxCounter && VminCounter){
// if(CV->_direction_up && CV->_current_direction_up){
// if(Vset >= CV->_Vinit){
// CV->_cycleNumber--;
// VminCounter = false;
// VmaxCounter = false;
// }
// }
// if(!CV->_direction_up && !CV->_current_direction_up){
// if(Vset <= CV->_Vinit){
// CV->_cycleNumber--;
// VminCounter = false;
// VmaxCounter = false;
// }
// }
// }
//
// if (Vset >= CV->_Vmax){
// CV->_current_direction_up = false;
// }else if (Vset <= CV->_Vmin){
// CV->_current_direction_up = true;
// }
//
// /*stop condition*/
// if(CV->_cycleNumber == 0){
// PeriodicEvent = false;
// ModeLED(NO_EVENT);
// }
// }
//}
#endif
@@ -3,48 +3,48 @@
#define Vset INSTRUCTION.Vset
static uint16_t CVSCANCurve(void *WM){
struct CVSCANMode *CVSCAN = (struct CVSCANMode *)WM;
static uint16_t DACOutCode;
static int32_t Vin;
static int32_t Vout;
static int32_t DeltaVout;
Vin = CVSCAN->_measureVin * 200;//[5nV]
if(DACReset){
Vout = Vset + Vin;
DACReset = false;
}else{
DeltaVout = Vset - (Vout - Vin);
Vout = Vout + DeltaVout;
}
INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant);
int32_t RealV2;
RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
InputNotify(NOTIFY_VOLT, RealV2);
int32_t RealV;
RealV = (int32_t)(Vout / 200);//[1uV]
InputNotify(NOTIFY_IMPEDANCE, RealV);
DAC_outputV(DACOutCode);
return DACOutCode;
}
static void CVSCAN_Vscan(void *WM){
struct CVSCANMode *CVSCAN = (struct CVSCANMode *)WM;
if(vscanReset){
Vset = CVSCAN->_Vinit;
}
if(!vscanReset){
Vset = CVSCAN->_Vinit;
}
}
//static uint16_t CVSCANCurve(void *WM){
// struct CVSCANMode *CVSCAN = (struct CVSCANMode *)WM;
//
// static uint16_t DACOutCode;
// static int32_t Vin;
// static int32_t Vout;
// static int32_t DeltaVout;
//
// Vin = CVSCAN->_measureVin * 200;//[5nV]
// if(DACReset){
// Vout = Vset + Vin;
// DACReset = false;
// }else{
// DeltaVout = Vset - (Vout - Vin);
// Vout = Vout + DeltaVout;
// }
//
// INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
// DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant);
//
// int32_t RealV2;
// RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
// InputNotify(NOTIFY_VOLT, RealV2);
//
// int32_t RealV;
// RealV = (int32_t)(Vout / 200);//[1uV]
// InputNotify(NOTIFY_IMPEDANCE, RealV);
//
// DAC_outputV(DACOutCode);
//
// return DACOutCode;
//}
//
//static void CVSCAN_Vscan(void *WM){
// struct CVSCANMode *CVSCAN = (struct CVSCANMode *)WM;
//
// if(vscanReset){
// Vset = CVSCAN->_Vinit;
// }
//
// if(!vscanReset){
// Vset = CVSCAN->_Vinit;
// }
//}
#endif
@@ -4,58 +4,59 @@
#define Vset INSTRUCTION.Vset
static void IV_Vscan(void *WM){
struct IVMode *IV = (struct IVMode *)WM;
//static void IV_Vscan(void *WM){
// struct IVMode *IV = (struct IVMode *)WM;
//
// if(vscanReset){
// if(INSTRUCTION.directionInit == 1){
// IV->_direction_up = true;
// IV->_current_direction_up = true;
// }else if(INSTRUCTION.directionInit == 0){
// IV->_direction_up = false;
// IV->_current_direction_up = false;
// }
//
// //Vsetp = x * 20 * N, x=xmV ; N=VscanRate
// if(INSTRUCTION.step <= 10){
// IV->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
// }else{
// IV->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
// }
//
// Vset = IV->_Vinit;
// }
//
// if(!vscanReset){
// if(IV->_current_direction_up){
// if(Vset >= IV->_Vmax){
// PeriodicEvent = false;
// ModeLED(NO_EVENT);
// }
// }else{
// if(Vset <= IV->_Vmin){
// PeriodicEvent = false;
// ModeLED(NO_EVENT);
// }
// }
//
// if (IV->_current_direction_up){
// Vset = Vset + IV->_Vstep * GPT.GptimerMultiple;
// }else{
// Vset = Vset - IV->_Vstep * GPT.GptimerMultiple;
// }
// }
//}
if(vscanReset){
if(INSTRUCTION.directionInit == 1){
IV->_direction_up = true;
IV->_current_direction_up = true;
}else if(INSTRUCTION.directionInit == 0){
IV->_direction_up = false;
IV->_current_direction_up = false;
}
static void VOUT_Vscan(void)
{
struct wm_vo_ctx_t *vo = (struct wm_vo_ctx_t *)wm_get();
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
if(INSTRUCTION.step <= 10){
IV->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
}else{
IV->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
}
Vset = IV->_Vinit;
if (vscanReset) {
Vset = vo->_Vinit;
}
if(!vscanReset){
if(IV->_current_direction_up){
if(Vset >= IV->_Vmax){
PeriodicEvent = false;
ModeLED(NO_EVENT);
}
}else{
if(Vset <= IV->_Vmin){
PeriodicEvent = false;
ModeLED(NO_EVENT);
}
}
if (IV->_current_direction_up){
Vset = Vset + IV->_Vstep * GPT.GptimerMultiple;
}else{
Vset = Vset - IV->_Vstep * GPT.GptimerMultiple;
}
}
}
static void VOUT_Vscan(void *WM){
struct VOMode *VO = (struct VOMode *)WM;
if(vscanReset){
Vset = VO->_Vinit;
}
if(!vscanReset){
Vset = VO->_Vinit;
if(!vscanReset) {
Vset = vo->_Vinit;
}
}
@@ -1,44 +1,14 @@
#ifndef __INSTR_H__
#define __INSTR_H__
#ifndef ELITEINSTRUCTION
#define ELITEINSTRUCTION
/** Iin, Vin, Vout **/
#define IIN_ADC 0x00
#define VIN_ADC 0x01
#define VOUT_DAC 0x02
#define HIGH_Z 0x03
/** ADC Iin gain level **/
#define I_GAIN_3M 0x00 // largest gain
#define I_GAIN_100K 0x01
#define I_GAIN_3K 0x02
#define I_GAIN_100R 0x03 // the least gain
#define I_GAIN_AUTO 0x04
/** ADC Vin gain level **/
#define VIN_GAIN_1M 0x00
#define VIN_GAIN_30K 0x01
#define VIN_GAIN_1K 0x02
#define VIN_GAIN_AUTO 0x03
/** Vout gain level **/
#define VOUT_GAIN_240K 0x00
#define VOUT_GAIN_15K 0x01
#define VOUT_GAIN_AUTO 0x02
/* DAC reset parameter */
#define DAC_ZERO 25000
// Step time macro
#define STEPTIME_HALF_SEC 5000
#define STEPTIME_ONE_SEC 10000
#define STEPTIME_TWO_SEC 20000
#ifdef __cpulsplus
extern "C" {
#endif
/*==============================
==== headstage instruction ====
=============================*/
struct HEADSTAGE_INSTRUCTION {
uint8_t chip_id;
uint8_t eliteFxn;
@@ -98,6 +68,38 @@ struct HEADSTAGE_INSTRUCTION {
} INSTRUCTION = {0};
/** Iin, Vin, Vout **/
#define IIN_ADC 0x00
#define VIN_ADC 0x01
#define VOUT_DAC 0x02
#define HIGH_Z 0x03
/** ADC Iin gain level **/
#define I_GAIN_3M 0x00 // largest gain
#define I_GAIN_100K 0x01
#define I_GAIN_3K 0x02
#define I_GAIN_100R 0x03 // the least gain
#define I_GAIN_AUTO 0x04
/** ADC Vin gain level **/
#define VIN_GAIN_1M 0x00
#define VIN_GAIN_30K 0x01
#define VIN_GAIN_1K 0x02
#define VIN_GAIN_AUTO 0x03
/** Vout gain level **/
#define VOUT_GAIN_240K 0x00
#define VOUT_GAIN_15K 0x01
#define VOUT_GAIN_AUTO 0x02
/* DAC reset parameter */
#define DAC_ZERO 25000
// Step time macro
#define STEPTIME_HALF_SEC 5000
#define STEPTIME_ONE_SEC 10000
#define STEPTIME_TWO_SEC 20000
/*********************************************************************
* @fn InitEliteInstruction
*
@@ -156,4 +158,10 @@ static void InitEliteInstruction(){
INSTRUCTION.sti_loop = 1;
INSTRUCTION.sti_cy = 0;
}
#ifdef __cpulsplus
}
#endif
#endif
@@ -159,7 +159,7 @@ static void WorkModeLED() {
case DIFFERENTIAL_PULSE_VOLTAMMETRY:
case SQUARE_WAVE_VOLTAMMETRY:
case VOLT_OUTPUT:
case ZT_CURVE:
case RT_CURVE:
case VT_CURVE:
case IT_CURVE:
case ADC_TEST:
@@ -3,99 +3,99 @@
#define Vset INSTRUCTION.Vset
static uint16_t LSVCurve(void *WM){
struct LSVMode *LSV = (struct LSVMode *)WM;
static uint16_t DACOutCode;
static int32_t Vin;
static int32_t Vout;
static int32_t DeltaVout;
Vin = LSV->_measureVin * 200;//[5nV]
if(DACReset){
Vout = Vset + Vin;
DACReset = false;
}else{
DeltaVout = Vset - (Vout - Vin);
Vout = Vout + DeltaVout;
}
INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant);
int32_t RealV2;
RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
InputNotify(NOTIFY_VOLT, RealV2);
int32_t RealV;
RealV = (int32_t)(Vout / 200);//[1uV]
InputNotify(NOTIFY_IMPEDANCE, RealV);
DAC_outputV(DACOutCode);
//static uint16_t LSVCurve(void *WM){
// struct LSVMode *LSV = (struct LSVMode *)WM;
//
return DACOutCode;
}
// static uint16_t DACOutCode;
// static int32_t Vin;
// static int32_t Vout;
// static int32_t DeltaVout;
//
// Vin = LSV->_measureVin * 200;//[5nV]
// if(DACReset){
// Vout = Vset + Vin;
// DACReset = false;
// }else{
// DeltaVout = Vset - (Vout - Vin);
// Vout = Vout + DeltaVout;
// }
//
// INSTRUCTION.VoltConstant = Vout / 40000 + 25000;//5nV=>usercode
// DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.VoltConstant);
//
// int32_t RealV2;
// RealV2 = (int32_t)((Vout - Vin) / 200);//[1uV]
// InputNotify(NOTIFY_VOLT, RealV2);
//
// int32_t RealV;
// RealV = (int32_t)(Vout / 200);//[1uV]
// InputNotify(NOTIFY_IMPEDANCE, RealV);
//
// DAC_outputV(DACOutCode);
////
// return DACOutCode;
//}
static void LSV_Vscan(void *WM){
struct LSVMode *LSV = (struct LSVMode *)WM;
NotifyCycleNumber = (INSTRUCTION.cycleNumber - LSV->_cycleNumber + 1);
if(vscanReset){
if(INSTRUCTION.directionInit == 1){
LSV->_direction_up = true;
LSV->_current_direction_up = true;
}else{
LSV->_direction_up = false;
LSV->_current_direction_up = false;
}
//Vsetp = x * 20 * N, x=xmV ; N=VscanRate
if(INSTRUCTION.step <= 10){
LSV->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
}else{
LSV->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
}
Vset = LSV->_Vinit;
}
if(!vscanReset){
if (LSV->_current_direction_up){
Vset = Vset + LSV->_Vstep * GPT.GptimerMultiple;
}else{
Vset = Vset - LSV->_Vstep * GPT.GptimerMultiple;
}
/*stop condition*/
if (Vset >= LSV->_Vmax){
ModeLED(POST_WORK);
// PeriodicEvent = false;
Vset = LSV->_Vmin;
InitEliteFlag();
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.charge = 0x01;
INSTRUCTION.constantCurrent = 0x00;
INSTRUCTION.Vmax = 0xC350;
INSTRUCTION.Vmin = 0x0000;
INSTRUCTION.notifyRate = 500;
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
}else if (Vset <= LSV->_Vmin){
ModeLED(POST_WORK);
// PeriodicEvent = false;
Vset = LSV->_Vmax;
InitEliteFlag();
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.charge = 0x01;
INSTRUCTION.constantCurrent = 0x00;
INSTRUCTION.Vmax = 0xC350;
INSTRUCTION.Vmin = 0x0000;
INSTRUCTION.notifyRate = 500;
INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
}
}
}
//static void LSV_Vscan(void *WM){
// struct LSVMode *LSV = (struct LSVMode *)WM;
//
// NotifyCycleNumber = (INSTRUCTION.cycleNumber - LSV->_cycleNumber + 1);
//
// if(vscanReset){
// if(INSTRUCTION.directionInit == 1){
// LSV->_direction_up = true;
// LSV->_current_direction_up = true;
// }else{
// LSV->_direction_up = false;
// LSV->_current_direction_up = false;
// }
//
// //Vsetp = x * 20 * N, x=xmV ; N=VscanRate
// if(INSTRUCTION.step <= 10){
// LSV->_Vstep = INSTRUCTION.step * INSTRUCTION.VsetRate / 5;
// }else{
// LSV->_Vstep = INSTRUCTION.step / 5 * INSTRUCTION.VsetRate;
// }
//
// Vset = LSV->_Vinit;
// }
//
// if(!vscanReset){
//
// if (LSV->_current_direction_up){
// Vset = Vset + LSV->_Vstep * GPT.GptimerMultiple;
// }else{
// Vset = Vset - LSV->_Vstep * GPT.GptimerMultiple;
// }
//
// /*stop condition*/
// if (Vset >= LSV->_Vmax){
// ModeLED(POST_WORK);
//// PeriodicEvent = false;
// Vset = LSV->_Vmin;
// InitEliteFlag();
// INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
// INSTRUCTION.sampleRate = 15;
// INSTRUCTION.charge = 0x01;
// INSTRUCTION.constantCurrent = 0x00;
// INSTRUCTION.Vmax = 0xC350;
// INSTRUCTION.Vmin = 0x0000;
// INSTRUCTION.notifyRate = 500;
// INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
// }else if (Vset <= LSV->_Vmin){
// ModeLED(POST_WORK);
//// PeriodicEvent = false;
// Vset = LSV->_Vmax;
// InitEliteFlag();
// INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
// INSTRUCTION.sampleRate = 15;
// INSTRUCTION.charge = 0x01;
// INSTRUCTION.constantCurrent = 0x00;
// INSTRUCTION.Vmax = 0xC350;
// INSTRUCTION.Vmin = 0x0000;
// INSTRUCTION.notifyRate = 500;
// INSTRUCTION.VoViSwitch = 0x02;//read Vscan = Vout - Vin
// }
// }
//}
#endif
@@ -3,111 +3,111 @@
#define Vset INSTRUCTION.Vset
static void PULSE_Vscan(void *WM){
struct PULSEMode *PULSE = (struct PULSEMode *)WM;
static uint16_t lastVolt;
if (stiFirstTime) {
stiFirstTime = false;
lastVolt = 25000;
PULSE->_sti_t_flag = 1;
PULSE->_sti_v = PULSE->_sti_v1;
PULSE->_sti_t = PULSE->_sti_t1;
if (PULSE->_sti_t == 1) {
PULSE->_sti_v = lastVolt;
}
} else if(!stiFirstTime) {
if (GPT.StiCounter >= PULSE->_sti_t) {
GPT.StiCounter -= PULSE->_sti_t; //to get right time
if (PULSE->_sti_lp > 0) {
if (PULSE->_sti_cy > 0) {
if (PULSE->_sti_t_flag == 1) {
PULSE->_sti_t_flag = 2;
PULSE->_sti_v = PULSE->_sti_v2;
PULSE->_sti_t = PULSE->_sti_t2;
if (PULSE->_sti_t == 1) {
PULSE->_sti_v = lastVolt;
}
} else if (PULSE->_sti_t_flag == 2) {
PULSE->_sti_t_flag = 3;
PULSE->_sti_v = PULSE->_sti_v3;
PULSE->_sti_t = PULSE->_sti_t3;
if (PULSE->_sti_t == 1) {
PULSE->_sti_v = lastVolt;
}
} else if (PULSE->_sti_t_flag == 3) {
PULSE->_sti_cy -- ;
if (PULSE->_sti_cy == 0) {
PULSE->_sti_t_flag = 4;
PULSE->_sti_v = PULSE->_sti_v4;
PULSE->_sti_t = PULSE->_sti_t4;
if (PULSE->_sti_t == 1) {
PULSE->_sti_v = lastVolt;
}
} else {
PULSE->_sti_t_flag = 2;
PULSE->_sti_v = PULSE->_sti_v2;
PULSE->_sti_t = PULSE->_sti_t2;
if (PULSE->_sti_t == 1) {
PULSE->_sti_v = lastVolt;
}
}
}
} else if (PULSE->_sti_cy <= 0){
if (PULSE->_sti_t_flag == 4) {
PULSE->_sti_lp -- ;
if (PULSE->_sti_lp > 0) {
PULSE->_sti_cy = INSTRUCTION.sti_cy;
PULSE->_sti_t_flag = 2;
PULSE->_sti_v = PULSE->_sti_v2;
PULSE->_sti_t = PULSE->_sti_t2;
if (PULSE->_sti_t == 1) {
PULSE->_sti_v = lastVolt;
}
} else {
PULSE->_sti_t_flag = 5;
PULSE->_sti_v = PULSE->_sti_v5;
PULSE->_sti_t = PULSE->_sti_t5;
if (PULSE->_sti_t == 1) {
PULSE->_sti_v = lastVolt;
}
}
}
}
} else if (PULSE->_sti_lp <= 0) {
if (PULSE->_sti_t_flag == 5) {
PULSE->_sti_t_flag = 6;
PULSE->_sti_v = PULSE->_sti_v6;
PULSE->_sti_t = PULSE->_sti_t6;
if (PULSE->_sti_t == 1) {
PULSE->_sti_v = lastVolt;
}
} else if (PULSE->_sti_t_flag == 6) {
PULSE->_sti_t_flag = 7;
PULSE->_sti_v = PULSE->_sti_v7;
PULSE->_sti_t = PULSE->_sti_t7;
if (PULSE->_sti_t == 1) {
PULSE->_sti_v = lastVolt;
}
} else if (PULSE->_sti_t_flag == 7) {
PULSE->_sti_v = 25000;
PeriodicEvent = false;
ModeLED(NO_EVENT);
}
}
}
}
if (lastVolt != PULSE->_sti_v) {
lastVolt = PULSE->_sti_v;
//if (PULSE->_sti_v == 25000) {
// PIN15_setOutputValue(HIGH_Z_MODE, 0); // 1 => close high_z mode
//} else {
// PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
//}
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, PULSE->_sti_v));
DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, PULSE->_sti_v));
}
}
//static void PULSE_Vscan(void){
// struct PULSEMode *PULSE = (struct PULSEMode *)WM;
//
// static uint16_t lastVolt;
// if (stiFirstTime) {
// stiFirstTime = false;
// lastVolt = 25000;
// PULSE->_sti_t_flag = 1;
// PULSE->_sti_v = PULSE->_sti_v1;
// PULSE->_sti_t = PULSE->_sti_t1;
// if (PULSE->_sti_t == 1) {
// PULSE->_sti_v = lastVolt;
// }
// } else if(!stiFirstTime) {
// if (GPT.StiCounter >= PULSE->_sti_t) {
// GPT.StiCounter -= PULSE->_sti_t; //to get right time
//
// if (PULSE->_sti_lp > 0) {
// if (PULSE->_sti_cy > 0) {
// if (PULSE->_sti_t_flag == 1) {
// PULSE->_sti_t_flag = 2;
// PULSE->_sti_v = PULSE->_sti_v2;
// PULSE->_sti_t = PULSE->_sti_t2;
// if (PULSE->_sti_t == 1) {
// PULSE->_sti_v = lastVolt;
// }
// } else if (PULSE->_sti_t_flag == 2) {
// PULSE->_sti_t_flag = 3;
// PULSE->_sti_v = PULSE->_sti_v3;
// PULSE->_sti_t = PULSE->_sti_t3;
// if (PULSE->_sti_t == 1) {
// PULSE->_sti_v = lastVolt;
// }
// } else if (PULSE->_sti_t_flag == 3) {
// PULSE->_sti_cy -- ;
// if (PULSE->_sti_cy == 0) {
// PULSE->_sti_t_flag = 4;
// PULSE->_sti_v = PULSE->_sti_v4;
// PULSE->_sti_t = PULSE->_sti_t4;
// if (PULSE->_sti_t == 1) {
// PULSE->_sti_v = lastVolt;
// }
// } else {
// PULSE->_sti_t_flag = 2;
// PULSE->_sti_v = PULSE->_sti_v2;
// PULSE->_sti_t = PULSE->_sti_t2;
// if (PULSE->_sti_t == 1) {
// PULSE->_sti_v = lastVolt;
// }
// }
// }
// } else if (PULSE->_sti_cy <= 0){
// if (PULSE->_sti_t_flag == 4) {
// PULSE->_sti_lp -- ;
// if (PULSE->_sti_lp > 0) {
// PULSE->_sti_cy = INSTRUCTION.sti_cy;
// PULSE->_sti_t_flag = 2;
// PULSE->_sti_v = PULSE->_sti_v2;
// PULSE->_sti_t = PULSE->_sti_t2;
// if (PULSE->_sti_t == 1) {
// PULSE->_sti_v = lastVolt;
// }
// } else {
// PULSE->_sti_t_flag = 5;
// PULSE->_sti_v = PULSE->_sti_v5;
// PULSE->_sti_t = PULSE->_sti_t5;
// if (PULSE->_sti_t == 1) {
// PULSE->_sti_v = lastVolt;
// }
// }
// }
// }
// } else if (PULSE->_sti_lp <= 0) {
// if (PULSE->_sti_t_flag == 5) {
// PULSE->_sti_t_flag = 6;
// PULSE->_sti_v = PULSE->_sti_v6;
// PULSE->_sti_t = PULSE->_sti_t6;
// if (PULSE->_sti_t == 1) {
// PULSE->_sti_v = lastVolt;
// }
// } else if (PULSE->_sti_t_flag == 6) {
// PULSE->_sti_t_flag = 7;
// PULSE->_sti_v = PULSE->_sti_v7;
// PULSE->_sti_t = PULSE->_sti_t7;
// if (PULSE->_sti_t == 1) {
// PULSE->_sti_v = lastVolt;
// }
// } else if (PULSE->_sti_t_flag == 7) {
// PULSE->_sti_v = 25000;
// PeriodicEvent = false;
// ModeLED(NO_EVENT);
// }
// }
// }
// }
//
// if (lastVolt != PULSE->_sti_v) {
// lastVolt = PULSE->_sti_v;
// //if (PULSE->_sti_v == 25000) {
// // PIN15_setOutputValue(HIGH_Z_MODE, 0); // 1 => close high_z mode
// //} else {
// // PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
// //}
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, PULSE->_sti_v));
// DAC_outputV(Usercode_Correction_to_DAC(VOUT_GAIN_240K, PULSE->_sti_v));
// }
//}
#endif
@@ -1,3 +1,6 @@
/*=============================================================================
= wm.h =
=============================================================================*/
#ifndef ELITE_WORK_DATA
#define ELITE_WORK_DATA
@@ -26,346 +29,452 @@ typedef void (*InitWorkData) ();
bool _current_direction_up; \
uint16_t _cycleNumber
#define MEASURE_CURRENT(_m) (((struct Measure *)(_m))->_measureCurrent)
#define MEASURE_VIN(_m) (((struct Measure *)(_m))->_measureVin)
#define MEASURE_VOUT(_m) (((struct Measure *)(_m))->_measureVout)
#define MEASURE_BAT(_m) (((struct Measure *)(_m))->_measureBat)
#define MEASURE_SWITCH(_m) (((struct Measure *)(_m))->_VoViSwitch)
#define MEASURE_CURRENT(_m) (((struct wm_meas_t *)(_m))->_measureCurrent)
#define MEASURE_VIN(_m) (((struct wm_meas_t *)(_m))->_measureVin)
#define MEASURE_VOUT(_m) (((struct wm_meas_t *)(_m))->_measureVout)
#define MEASURE_BAT(_m) (((struct wm_meas_t *)(_m))->_measureBat)
#define MEASURE_SWITCH(_m) (((struct wm_meas_t *)(_m))->_VoViSwitch)
struct Measure{
MEASURE;
struct wm_meas_t {
int32_t _measureCurrent;
int32_t _measureVin;
int32_t _measureVout;
int32_t _measureBat;
uint8_t _VoViSwitch;
};
struct VoltOutPara{
VOUT_PARA;
};
/***** End of Measure and VoltOut parameter *****/
/* member of mode */
struct VOMode{
struct wm_vo_ctx_t {
/* WARNING: please keep MEASURE at first!! */
MEASURE;
struct wm_meas_t measure;
int32_t _Vset;
int32_t _Vinit;
};
int32_t _Vset;
int32_t _Vinit;
}; /* VO Mode Data */
struct ITMode{
struct wm_it_ctx_t {
/* WARNING: please keep MEASURE at first!! */
MEASURE;
}; /* IT Mode Data */
struct wm_meas_t measure;
};
struct VTMode{
struct wm_vt_ctx_t {
/* WARNING: please keep MEASURE at first!! */
MEASURE;
}; /* VT Mode Data */
struct wm_meas_t measure;
};
struct RTMode{
struct wm_rt_ctx_t {
/* WARNING: please keep MEASURE at first!! */
MEASURE;
struct wm_meas_t measure;
int32_t _Vset;
int32_t _Vinit;
};
int32_t _Vset;
}; /* RT Mode Data */
//struct IVMode {
// /* WARNING: please keep MEASURE at first!! */
// struct wm_meas_t measure;
//
// VOUT_PARA;
//};
struct IVMode{
/* WARNING: please keep MEASURE at first!! */
MEASURE;
//struct CVMode {
// /* WARNING: please keep MEASURE at first!! */
// struct wm_meas_t measure;
//
// VOUT_PARA;
//};
VOUT_PARA;
}; /* IV Mode Data */
//struct CCMode {
// /* WARNING: please keep MEASURE at first!! */
// struct wm_meas_t measure;
//
// int32_t _Vmax;
// int32_t _Vmin;
// int32_t _Vset;
// int32_t _Iset;
// uint8_t _charge;
//};
struct CVMode{
/* WARNING: please keep MEASURE at first!! */
MEASURE;
//struct CV3Mode {
// /* WARNING: please keep MEASURE at first!! */
// struct wm_meas_t measure;
//
// VOUT_PARA;
//};
VOUT_PARA;
}; /* CV Mode(CYCLE_IV) */
//struct LSVMode {
// /* WARNING: please keep MEASURE at first!! */
// struct wm_meas_t measure;
//
// VOUT_PARA;
//};
struct CCMode{
/* WARNING: please keep MEASURE at first!! */
MEASURE;
//struct CVSCANMode {
// /* WARNING: please keep MEASURE at first!! */
// struct wm_meas_t measure;
//
// int32_t _Vinit;
// int32_t _Vset;
//};
int32_t _Vmax;
int32_t _Vmin;
int32_t _Vset;
int32_t _Iset;
uint8_t _charge;
}; /* CC Mode Data */
//struct PULSEMode {
// /* WARNING: please keep MEASURE at first!! */
// struct wm_meas_t measure;
//
// int32_t _Vset;
// int32_t _sti_v1;
// int32_t _sti_v2;
// int32_t _sti_v3;
// int32_t _sti_v4;
// int32_t _sti_v5;
// int32_t _sti_v6;
// int32_t _sti_v7;
// int32_t _sti_t1;
// int32_t _sti_t2;
// int32_t _sti_t3;
// int32_t _sti_t4;
// int32_t _sti_t5;
// int32_t _sti_t6;
// int32_t _sti_t7;
// int32_t _sti_t;
// int32_t _sti_v; //output voltage now
// int32_t _sti_t_flag; //Where's the time stage turn
// uint16_t _sti_cy;
// uint16_t _sti_lp;
//};
struct CV3Mode{
/* WARNING: please keep MEASURE at first!! */
MEASURE;
int wm_init(void); //(void *instr_ctx);
int wm_deinit(void);
void *wm_get(void);
VOUT_PARA;
}; /* CV3 Mode(CYCLIC_VOLTAMMETRY) */
struct LSVMode{
/* WARNING: please keep MEASURE at first!! */
MEASURE;
VOUT_PARA;
}; /* LSV Mode(LINEAR_SWEEP_VOLTAMMETRY) */
struct CVSCANMode{
/* WARNING: please keep MEASURE at first!! */
MEASURE;
int32_t _Vinit;
int32_t _Vset;
}; /* CONSTANT_VSCAN Mode(CONSTANT_VSCAN) */
struct PULSEMode {
/* WARNING: please keep MEASURE at first!! */
MEASURE;
int32_t _Vset;
int32_t _sti_v1;
int32_t _sti_v2;
int32_t _sti_v3;
int32_t _sti_v4;
int32_t _sti_v5;
int32_t _sti_v6;
int32_t _sti_v7;
int32_t _sti_t1;
int32_t _sti_t2;
int32_t _sti_t3;
int32_t _sti_t4;
int32_t _sti_t5;
int32_t _sti_t6;
int32_t _sti_t7;
int32_t _sti_t;
int32_t _sti_v; //output voltage now
int32_t _sti_t_flag; //Where's the time stage turn
uint16_t _sti_cy;
uint16_t _sti_lp;
}; /* PULSE_MODE Mode(PULSE_MODE) */
/*=============================================================================
= wm.c =
=============================================================================*/
static void *workMode_p = NULL;
/* init mode func */
void *InitVoltOutMode(){
struct VOMode *ret = malloc(sizeof(struct VOMode));
ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
ret->_Vset = 0;
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 8;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
return (void *)ret;
} /* VO Mode */
void *InitITMode(){
struct ITMode *ret = malloc(sizeof(struct ITMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
return (void *)ret;
} /* IT Mode */
void *InitVTMode(){
struct VTMode *ret = malloc(sizeof(struct VTMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 6789;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
return (void *)ret;
} /* VT Mode */
void *InitRTMode(){
struct RTMode *ret = malloc(sizeof(struct RTMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
ret->_Vset = INSTRUCTION.VoltConstant;
return (void *)ret;
} /* RT Mode */
void *InitIVMode(){
struct IVMode *ret = malloc(sizeof(struct IVMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
ret->_Vset = 0;
ret->_Vstep = 0;
ret->_direction_up = true;
ret->_current_direction_up = true;
ret->_cycleNumber = INSTRUCTION.cycleNumber;
return (void *)ret;
} /* IV Mode */
void *InitCVMode(){
struct CVMode *ret = malloc(sizeof(struct CVMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
ret->_Vset = 0;
ret->_Vstep = 0;
ret->_direction_up = true;
ret->_current_direction_up = true;
ret->_cycleNumber = INSTRUCTION.cycleNumber;
return (void *)ret;
} /* CV Mode */
void *InitCCMode(){
struct CCMode *ret = malloc(sizeof(struct CCMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
ret->_Vset = 0;
ret->_Iset = INSTRUCTION.constantCurrent * 200 ; //[50pA] //controller UI 15000uA => Elite 1500000 => 1500000 * 10 * 1000 / 50 [50pA]
ret->_charge = INSTRUCTION.charge;
return (void *)ret;
} /* CC Mode */
void *InitCV3Mode(){
struct CV3Mode *ret = malloc(sizeof(struct CV3Mode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
ret->_Vset = 0;
ret->_Vstep = 0;
ret->_direction_up = true;
ret->_current_direction_up = true;
ret->_cycleNumber = INSTRUCTION.cycleNumber;
return (void *)ret;
} /* CV3 Mode */
void *InitLSVMode(){
struct LSVMode *ret = malloc(sizeof(struct LSVMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
ret->_Vset = 0;
ret->_Vstep = 0;
ret->_direction_up = true;
ret->_current_direction_up = true;
ret->_cycleNumber = INSTRUCTION.cycleNumber;
return (void *)ret;
} /* LSV Mode */
void *InitCVSCANMode(){
struct CVSCANMode *ret = malloc(sizeof(struct CVSCANMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
ret->_Vset = 0;
return (void *)ret;
} /* CONSTANT_VSCAN Mode */
void *InitPULSEMode() {
struct PULSEMode *ret = malloc(sizeof(struct PULSEMode));
ret->_measureCurrent = 0;
ret->_measureVin = 0;
ret->_measureVout = 0;
ret->_measureBat = 0;
ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
ret->_Vset = 0;
ret->_sti_v1 = INSTRUCTION.sti_v1;
ret->_sti_v2 = INSTRUCTION.sti_v2;
ret->_sti_v3 = INSTRUCTION.sti_v3;
ret->_sti_v4 = INSTRUCTION.sti_v4;
ret->_sti_v5 = INSTRUCTION.sti_v5;
ret->_sti_v6 = INSTRUCTION.sti_v6;
ret->_sti_v7 = INSTRUCTION.sti_v7;
ret->_sti_t1 = INSTRUCTION.sti_t1;
ret->_sti_t2 = INSTRUCTION.sti_t2;
ret->_sti_t3 = INSTRUCTION.sti_t3;
ret->_sti_t4 = INSTRUCTION.sti_t4;
ret->_sti_t5 = INSTRUCTION.sti_t5;
ret->_sti_t6 = INSTRUCTION.sti_t6;
ret->_sti_t7 = INSTRUCTION.sti_t7;
ret->_sti_t = INSTRUCTION.sti_t1;
ret->_sti_v = INSTRUCTION.sti_v1;
ret->_sti_t_flag = 1;
ret->_sti_cy = INSTRUCTION.sti_cy;
ret->_sti_lp = INSTRUCTION.sti_loop;
return (void *)ret;
} /* PULSE_MODE Mode */
void InitWorkMode(void **WM)
static int __vo_create(void)
{
switch(INSTRUCTION.eliteFxn) {
struct wm_meas_t *m;
struct wm_vo_ctx_t *p;
void **wm = &workMode_p;
p = malloc(sizeof(struct wm_vo_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 = INSTRUCTION.VoViSwitch;
p->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
p->_Vset = 0;
*wm = p;
return 0;
}
static int __it_create(void)
{
struct wm_meas_t *m;
struct wm_it_ctx_t *p;
void **wm = &workMode_p;
p = malloc(sizeof(struct wm_it_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 = INSTRUCTION.VoViSwitch;
*wm = p;
return 0;
}
static int __vt_create(void)
{
struct wm_meas_t *m;
struct wm_vt_ctx_t *p;
void **wm = &workMode_p;
p = malloc(sizeof(struct wm_vt_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 = INSTRUCTION.VoViSwitch;
*wm = p;
return 0;
}
static int __rt_create(void)
{
struct wm_meas_t *m;
struct wm_rt_ctx_t *p;
void **wm = &workMode_p;
p = malloc(sizeof(struct wm_rt_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 = INSTRUCTION.VoViSwitch;
p->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
p->_Vset = 0;
*wm = p;
return 0;
}
//void *InitIVMode(){
// struct IVMode *ret = malloc(sizeof(struct IVMode));
// ret->_measureCurrent = 0;
// ret->_measureVin = 0;
// ret->_measureVout = 0;
// ret->_measureBat = 0;
// ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
// ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
// ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
// ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
// ret->_Vset = 0;
// ret->_Vstep = 0;
// ret->_direction_up = true;
// ret->_current_direction_up = true;
// ret->_cycleNumber = INSTRUCTION.cycleNumber;
// return (void *)ret;
//} /* IV Mode */
//void *InitCVMode(){
// struct CVMode *ret = malloc(sizeof(struct CVMode));
// ret->_measureCurrent = 0;
// ret->_measureVin = 0;
// ret->_measureVout = 0;
// ret->_measureBat = 0;
// ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
// ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
// ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
// ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
// ret->_Vset = 0;
// ret->_Vstep = 0;
// ret->_direction_up = true;
// ret->_current_direction_up = true;
// ret->_cycleNumber = INSTRUCTION.cycleNumber;
// return (void *)ret;
//} /* CV Mode */
//void *InitCCMode(){
// struct CCMode *ret = malloc(sizeof(struct CCMode));
// ret->_measureCurrent = 0;
// ret->_measureVin = 0;
// ret->_measureVout = 0;
// ret->_measureBat = 0;
// ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
// ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
// ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
// ret->_Vset = 0;
// ret->_Iset = INSTRUCTION.constantCurrent * 200 ; //[50pA] //controller UI 15000uA => Elite 1500000 => 1500000 * 10 * 1000 / 50 [50pA]
// ret->_charge = INSTRUCTION.charge;
// return (void *)ret;
//} /* CC Mode */
//void *InitCV3Mode(){
// struct CV3Mode *ret = malloc(sizeof(struct CV3Mode));
// ret->_measureCurrent = 0;
// ret->_measureVin = 0;
// ret->_measureVout = 0;
// ret->_measureBat = 0;
// ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
// ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
// ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
// ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
// ret->_Vset = 0;
// ret->_Vstep = 0;
// ret->_direction_up = true;
// ret->_current_direction_up = true;
// ret->_cycleNumber = INSTRUCTION.cycleNumber;
// return (void *)ret;
//} /* CV3 Mode */
//void *InitLSVMode(){
// struct LSVMode *ret = malloc(sizeof(struct LSVMode));
// ret->_measureCurrent = 0;
// ret->_measureVin = 0;
// ret->_measureVout = 0;
// ret->_measureBat = 0;
// ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
// ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
// ret->_Vmax = (INSTRUCTION.Vmax - 25000) * 4 * 10000; //[5nV]
// ret->_Vmin = (INSTRUCTION.Vmin - 25000) * 4 * 10000; //[5nV]
// ret->_Vset = 0;
// ret->_Vstep = 0;
// ret->_direction_up = true;
// ret->_current_direction_up = true;
// ret->_cycleNumber = INSTRUCTION.cycleNumber;
// return (void *)ret;
//} /* LSV Mode */
//void *InitCVSCANMode(){
// struct CVSCANMode *ret = malloc(sizeof(struct CVSCANMode));
// ret->_measureCurrent = 0;
// ret->_measureVin = 0;
// ret->_measureVout = 0;
// ret->_measureBat = 0;
// ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
// ret->_Vinit = (INSTRUCTION.Vinit - 25000) * 4 * 10000; //[5nV]
// ret->_Vset = 0;
// return (void *)ret;
//} /* CONSTANT_VSCAN Mode */
//void *InitPULSEMode() {
// struct PULSEMode *ret = malloc(sizeof(struct PULSEMode));
// ret->_measureCurrent = 0;
// ret->_measureVin = 0;
// ret->_measureVout = 0;
// ret->_measureBat = 0;
// ret->_VoViSwitch = INSTRUCTION.VoViSwitch;
// ret->_Vset = 0;
// ret->_sti_v1 = INSTRUCTION.sti_v1;
// ret->_sti_v2 = INSTRUCTION.sti_v2;
// ret->_sti_v3 = INSTRUCTION.sti_v3;
// ret->_sti_v4 = INSTRUCTION.sti_v4;
// ret->_sti_v5 = INSTRUCTION.sti_v5;
// ret->_sti_v6 = INSTRUCTION.sti_v6;
// ret->_sti_v7 = INSTRUCTION.sti_v7;
// ret->_sti_t1 = INSTRUCTION.sti_t1;
// ret->_sti_t2 = INSTRUCTION.sti_t2;
// ret->_sti_t3 = INSTRUCTION.sti_t3;
// ret->_sti_t4 = INSTRUCTION.sti_t4;
// ret->_sti_t5 = INSTRUCTION.sti_t5;
// ret->_sti_t6 = INSTRUCTION.sti_t6;
// ret->_sti_t7 = INSTRUCTION.sti_t7;
// ret->_sti_t = INSTRUCTION.sti_t1;
// ret->_sti_v = INSTRUCTION.sti_v1;
// ret->_sti_t_flag = 1;
// ret->_sti_cy = INSTRUCTION.sti_cy;
// ret->_sti_lp = INSTRUCTION.sti_loop;
// return (void *)ret;
//} /* PULSE_MODE Mode */
//void InitWorkMode(void **WM)
//{
// switch(INSTRUCTION.eliteFxn) {
// case VOLT_OUTPUT:
// case CALI_DAC_MODE:
// *WM = InitVoltOutMode();
// break;
// case IT_CURVE:
// *WM = InitITMode();
// break;
// case VT_CURVE:
// *WM = InitVTMode();
// break;
// case RT_CURVE:
// *WM = InitRTMode();
// break;
// case IV_CURVE:
// *WM = InitIVMode();
// break;
// case CV_CURVE:
// *WM = InitCVMode();
// break;
// case CONSTANT_CURRENT:
// *WM = InitCCMode();
// break;
// case CYCLIC_VOLTAMMETRY:
// *WM = InitCV3Mode();
// break;
// case LINEAR_SWEEP_VOLTAMMETRY:
// *WM = InitLSVMode();
// break;
// case CONSTANT_VSCAN:
// *WM = InitCVSCANMode();
// break;
// case PULSE_MODE:
// *WM = InitPULSEMode();
// break;
// default:
// *WM = InitVTMode();
// break;
// }
//}
int wm_init(void) //(void *instr_ctx)
{
int mode = INSTRUCTION.eliteFxn;//instr->curr_mode;
void **wm = &workMode_p;
if (*wm) return -1;
switch (mode) {
case VOLT_OUTPUT:
case CALI_DAC_MODE:
*WM = InitVoltOutMode();
if (__vo_create()) return -2;
break;
case IT_CURVE:
*WM = InitITMode();
if (__it_create()) return -2;
break;
case VT_CURVE:
*WM = InitVTMode();
if (__vt_create()) return -2;
break;
case ZT_CURVE:
*WM = InitRTMode();
break;
case IV_CURVE:
*WM = InitIVMode();
break;
case CV_CURVE:
*WM = InitCVMode();
break;
case CONSTANT_CURRENT:
*WM = InitCCMode();
break;
case CYCLIC_VOLTAMMETRY:
*WM = InitCV3Mode();
break;
case LINEAR_SWEEP_VOLTAMMETRY:
*WM = InitLSVMode();
break;
case CONSTANT_VSCAN:
*WM = InitCVSCANMode();
break;
case PULSE_MODE:
*WM = InitPULSEMode();
case RT_CURVE:
if (__rt_create()) return -2;
break;
default:
*WM = InitVTMode();
break;
}
// printf("DO NOT support!!");
return -3;
};
return 0;
}
void FreeWorkMode(void **WM)
//void FreeWorkMode(void **WM)
//{
// if (*WM) {
// free(*WM);
// *WM = NULL;
// }
//}
int wm_deinit(void)
{
if (*WM) {
free(*WM);
*WM = NULL;
void **wm = &workMode_p;
if (*wm) {
free(*wm);
*wm = NULL;
} else {
return -1;
}
return 0;
}
void *wm_get(void)
{
void *wm = workMode_p;
return wm;
}
/* CC Mode parameter
* @ Measure : measure current value (nA)
@@ -8,16 +8,16 @@
// change the output voltage step
// => get a R-T curve (with resolution = 1 sample/volt step )
static void ZT_Vscan(void *WM){
struct RTMode *RT = (struct RTMode *)WM;
static void ZT_Vscan(void)
{
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
if(vscanReset){
Vset = ((int32_t)(INSTRUCTION.VoltConstant) - 25000) * 4 * 10000; //[5nV]
OneWayVoltScan();
if (vscanReset) {
Vset = rt->_Vinit;
}
if(!vscanReset){
if(!vscanReset) {
Vset = rt->_Vinit;
}
}
#endif
@@ -24,7 +24,7 @@ enum all_mode_e {
IV_CURVE = 0x10,
CV_CURVE = 0x20,
VOLT_OUTPUT = 0x30,
ZT_CURVE = 0x40,
RT_CURVE = 0x40,
VT_CURVE = 0x50,
IT_CURVE = 0x60,
SET_SAMPLE_RATE = 0x70,
@@ -3,10 +3,7 @@
#define Vset INSTRUCTION.Vset
static void readIin(void *WM);
static int32_t readVinVout(void *WM);
static uint16_t OneWayVoltScan() {
static void OneWayVoltScan() {
static uint16_t DACOutCode;
static int32_t Vout;
static int32_t DeltaVout;
@@ -36,76 +33,64 @@ static uint16_t OneWayVoltScan() {
InputNotify(NOTIFY_IMPEDANCE, RealV);
}
return DACOutCode;
return;
}
static void CalcuResistance(struct RTMode *RT, int32_t VoltData){
static void CalcuResistance()
{
/* Elite 100 = 100R
Elite 1000 = 1KR
Elite 10000 = 10KR
Elite 100000 = 100KR
Elite 1000000 = 1MR
*/
static int32_t resister_32 = 0;
int32_t Vtemp;
Vtemp = (VoltData * 1000) - (RT->_measureCurrent * 10); //V = Vin - Iin * 10
resister_32 = Vtemp / RT->_measureCurrent; //R = V / Iin;
InputNotify(NOTIFY_IMPEDANCE, resister_32);
Elite 1000 = 1KR
Elite 10000 = 10KR
Elite 100000 = 100KR
Elite 1000000 = 1MR
*/
struct wm_rt_ctx_t *rt = (struct wm_rt_ctx_t *)wm_get();
struct wm_meas_t *m = &rt->measure;
int32_t resist;
int32_t volt;
volt = (m->_measureVin * 1000) - (m->_measureCurrent * 10); //V = Vin - Iin * 10
resist = volt / m->_measureCurrent; //R = V / Iin;
InputNotify(NOTIFY_IMPEDANCE, resist);
}
static void DACenable(void *WM, int32_t VoltData ,uint8_t afterRead){
if(afterRead == AFTER_READ_I){
static void DACenable(uint8_t afterRead){
void *wm = wm_get();
if (afterRead == AFTER_READ_I) {
switch (INSTRUCTION.eliteFxn) {
case CONSTANT_CURRENT:{
CC_Vscan(WM);
OneWayVoltScan();
break;
}
case VOLT_OUTPUT:
case IV_CURVE:
case CV_CURVE:
case ZT_CURVE:
case IT_CURVE:
case VT_CURVE:
case CYCLIC_VOLTAMMETRY:
case LINEAR_SWEEP_VOLTAMMETRY:
case CONSTANT_VSCAN:
case PULSE_MODE:{
break;
}
default:{
break;
}
}
}else if(afterRead == AFTER_READ_V){
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:
case CV_CURVE:
case VOLT_OUTPUT:{
OneWayVoltScan();
break;
}
case ZT_CURVE:{
CalcuResistance((struct RTMode *)WM, VoltData);
break;
}
case IT_CURVE:
case VT_CURVE:
case CONSTANT_CURRENT:
case PULSE_MODE:{
// CC_Vscan();
// OneWayVoltScan();
break;
}
default:
break;
}
} else if (afterRead == AFTER_READ_V) {
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:
case CV_CURVE:
case VOLT_OUTPUT:
OneWayVoltScan();
break;
case RT_CURVE:
OneWayVoltScan();
CalcuResistance();
break;
case CYCLIC_VOLTAMMETRY:{
CV3Curve(WM);
// CV3Curve(wm);
break;
}
case LINEAR_SWEEP_VOLTAMMETRY:{
LSVCurve(WM);
// LSVCurve(wm);
break;
}
case CONSTANT_VSCAN:{
CVSCANCurve((struct CVSCANMode *)WM);
// CVSCANCurve((struct CVSCANMode *)wm);
break;
}
default:{
@@ -115,233 +100,258 @@ static void DACenable(void *WM, int32_t VoltData ,uint8_t afterRead){
}
}
static void CC_Plot(void *WM){
static void CC_Plot(void)
{
static uint8_t ADCSwitch = 0;
static uint8_t BatSwitch = 0;
static int32_t VoltData = 0;
void *wm = wm_get();
if(batteryCheck_flag){
if(BatSwitch == 0){
if(ADCSwitch == 0){ /**read Iin(buffer),read bat**/
readIin(WM);
if(record_flag == false){
if (batteryCheck_flag) {
if (BatSwitch == 0) {
if (ADCSwitch == 0) { /**read Iin(buffer),read bat**/
if (INSTRUCTION.AutoGainEnable) {
MEASURE_CURRENT(wm) = AutoGainReadIin(spi_ADC_rxbuf);
AutoGainChangeIin(MEASURE_CURRENT(wm));
} else {
ReadADCIin(spi_ADC_rxbuf);
MEASURE_CURRENT(wm) = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
if (lastIinADCGainLevel != INSTRUCTION.ADCGainLevel) {
IinADCGainControl(INSTRUCTION.ADCGainLevel);
record_flag = false;
}
}
if (record_flag == false) {
static int recordCount = 0;
recordCount++;
if(recordCount == 2){
if (recordCount == 2) {
record_flag = true;
recordCount = 0;
}
}else{
InputNotify(NOTIFY_CURRENT, MEASURE_CURRENT(WM));
} else {
InputNotify(NOTIFY_CURRENT, MEASURE_CURRENT(wm));
}
DACenable(WM, VoltData, AFTER_READ_I);
DACenable(AFTER_READ_I);
ReadADCBat(spi_ADC_rxbuf);
BatSwitch++;
}else if(ADCSwitch == 1 || ADCSwitch == 3){ /**read Bat**/
} else if(ADCSwitch == 1 || ADCSwitch == 3) { /**read Bat**/
ReadADCBat(spi_ADC_rxbuf);
BatSwitch++;
}else if(ADCSwitch == 2){ /**read V(buffer),read bat**/
VoltData = readVinVout(WM);
if(INSTRUCTION.VoViSwitch == 0x02){
int32_t Vscan = (Vset / 200 - MEASURE_VIN(WM));
} else if(ADCSwitch == 2) { /**read V(buffer),read bat**/
if (MEASURE_SWITCH(wm) == 0x01 || MEASURE_SWITCH(wm) == 0x02) {
if (INSTRUCTION.VinAutoGainEnable) {
MEASURE_VIN(wm) = AutoGainReadVin(spi_ADC_rxbuf);
AutoGainChangeVin(MEASURE_VIN(wm));
} else {
ReadADCVolt(MEASURE_SWITCH(wm));
MEASURE_VIN(wm) = DecodeADCValue(INSTRUCTION.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
if (lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel) {
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
record_flag = false;
}
}
VoltData = MEASURE_VIN(wm);
} else if (MEASURE_SWITCH(wm) == 0x00) {
ReadADCVolt(MEASURE_SWITCH(wm));
MEASURE_VOUT(wm) = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
VoltData = MEASURE_VOUT(wm);
}
if (INSTRUCTION.VoViSwitch == 0x02) {
int32_t Vscan = (Vset / 200 - MEASURE_VIN(wm));
Vscan = (int32_t)(Vscan);//[1uV]
InputNotify(NOTIFY_VOLT, Vscan);
}else{
} else {
InputNotify(NOTIFY_VOLT, VoltData);
}
DACenable(WM, VoltData, AFTER_READ_V);
DACenable(AFTER_READ_V);
ReadADCBat(spi_ADC_rxbuf);
BatSwitch++;
}
}else if(BatSwitch == 1){
} else if(BatSwitch == 1) {
ReadADCBat(spi_ADC_rxbuf);
BatSwitch++;
}else if(BatSwitch == 2){
} else if(BatSwitch == 2) {
headstage_battery_volt();
ReadADCIin(spi_ADC_rxbuf);
batteryCheck_flag = false;
BatSwitch = 0;
ADCSwitch = 3;
}
}else{
} else {
BatSwitch = 0;
if(ADCSwitch == 0){ /**read Iin(buffer),read V**/
readIin(WM);
if(record_flag == false){
if (ADCSwitch == 0) { /**read Iin(buffer),read V**/
if (INSTRUCTION.AutoGainEnable) {
MEASURE_CURRENT(wm) = AutoGainReadIin(spi_ADC_rxbuf);
AutoGainChangeIin(MEASURE_CURRENT(wm));
} else {
ReadADCIin(spi_ADC_rxbuf);
MEASURE_CURRENT(wm) = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
if (lastIinADCGainLevel != INSTRUCTION.ADCGainLevel) {
IinADCGainControl(INSTRUCTION.ADCGainLevel);
record_flag = false;
}
}
if (record_flag == false) {
static int recordCount = 0;
recordCount++;
if(recordCount == 2){
if (recordCount == 2) {
record_flag = true;
recordCount = 0;
}
}else{
InputNotify(NOTIFY_CURRENT, MEASURE_CURRENT(WM));
} else {
InputNotify(NOTIFY_CURRENT, MEASURE_CURRENT(wm));
}
DACenable(WM, VoltData, AFTER_READ_I);
DACenable(AFTER_READ_I);
ReadADCVolt(MEASURE_SWITCH(WM));
ReadADCVolt(MEASURE_SWITCH(wm));
ADCSwitch++;
}
else if(ADCSwitch == 1){ /**read V**/
ReadADCVolt(MEASURE_SWITCH(WM));
} else if(ADCSwitch == 1) { /**read V**/
ReadADCVolt(MEASURE_SWITCH(wm));
ADCSwitch++;
}
else if(ADCSwitch == 2){ /**read V(buffer),read Iin**/
VoltData = readVinVout(WM);
if(INSTRUCTION.VoViSwitch == 0x02){
int32_t Vscan = (Vset / 200 - MEASURE_VIN(WM));
Vscan = (int32_t)(Vscan);//[1uV]
InputNotify(NOTIFY_VOLT, Vscan);
}else{
InputNotify(NOTIFY_VOLT, VoltData);
}
DACenable(WM, VoltData, AFTER_READ_V);
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch++;
}
else if(ADCSwitch == 3){ /**read Iin**/
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch = 0;
}
}
}
static void IT_Plot(void *WM) {
static uint8_t ADCSwitch = 0;
if(batteryCheck_flag){
EliteADCBattery();
if(!batteryCheck_flag){
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch = 2;
}
}else{
if(ADCSwitch == 0){ /**read Iin(buffer)**/
readIin(WM);
if(record_flag == false){
static int recordCount = 0;
recordCount++;
if(recordCount == 2){
record_flag = true;
recordCount = 0;
}
}else{
InputNotify(NOTIFY_CURRENT, MEASURE_CURRENT(WM));
}
ADCSwitch++;
}
else if(ADCSwitch == 1){ /**read Iin**/
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch++;
}
else if(ADCSwitch == 2){ /**read Iin**/
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch = 0;
}
}
}
static void VT_Plot(void *WM) {
static uint8_t ADCSwitch = 0;
static int32_t VoltData;
if(batteryCheck_flag){
EliteADCBattery();
if(!batteryCheck_flag){
ReadADCVolt(MEASURE_SWITCH(WM));
ADCSwitch = 2;
}
}else{
if(ADCSwitch == 0){ /**read V(buffer)**/
if(MEASURE_SWITCH(WM) == 0x01 || MEASURE_SWITCH(WM) == 0x02){
if(INSTRUCTION.VinAutoGainEnable){
MEASURE_VIN(WM) = AutoGainReadVin(spi_ADC_rxbuf);
AutoGainChangeVin(MEASURE_VIN(WM));
}else{
ReadADCVolt(MEASURE_SWITCH(WM));
MEASURE_VIN(WM) = DecodeADCValue(INSTRUCTION.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
if(lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel){
} else if(ADCSwitch == 2) { /**read V(buffer),read Iin**/
if (MEASURE_SWITCH(wm) == 0x01 || MEASURE_SWITCH(wm) == 0x02) {
if (INSTRUCTION.VinAutoGainEnable) {
MEASURE_VIN(wm) = AutoGainReadVin(spi_ADC_rxbuf);
AutoGainChangeVin(MEASURE_VIN(wm));
} else {
ReadADCVolt(MEASURE_SWITCH(wm));
MEASURE_VIN(wm) = DecodeADCValue(INSTRUCTION.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
if (lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel) {
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
record_flag = false;
}
}
VoltData = MEASURE_VIN(WM);
}else if(MEASURE_SWITCH(WM) == 0x00){
ReadADCVolt(MEASURE_SWITCH(WM));
MEASURE_VOUT(WM) = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
VoltData = MEASURE_VOUT(WM);
VoltData = MEASURE_VIN(wm);
} else if (MEASURE_SWITCH(wm) == 0x00) {
ReadADCVolt(MEASURE_SWITCH(wm));
MEASURE_VOUT(wm) = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
VoltData = MEASURE_VOUT(wm);
}
if(record_flag == false){
static int recordCount = 0;
recordCount++;
if(recordCount == 2){
record_flag = true;
recordCount = 0;
}
}else{
if (INSTRUCTION.VoViSwitch == 0x02) {
int32_t Vscan = (Vset / 200 - MEASURE_VIN(wm));
Vscan = (int32_t)(Vscan);//[1uV]
InputNotify(NOTIFY_VOLT, Vscan);
} else {
InputNotify(NOTIFY_VOLT, VoltData);
}
DACenable(AFTER_READ_V);
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch++;
}
else if(ADCSwitch == 1){ /**read V**/
ReadADCVolt(MEASURE_SWITCH(WM));
ADCSwitch++;
}
else if(ADCSwitch == 2){ /**read V**/
ReadADCVolt(MEASURE_SWITCH(WM));
} else if (ADCSwitch == 3) { /**read Iin**/
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch = 0;
}
}
// InputNotify(NOTIFY_CURRENT, MEASURE_SWITCH(WM));
}
static void readIin(void *WM){
if(INSTRUCTION.AutoGainEnable){
MEASURE_CURRENT(WM) = AutoGainReadIin(spi_ADC_rxbuf);
AutoGainChangeIin(MEASURE_CURRENT(WM));
}else{
ReadADCIin(spi_ADC_rxbuf);
MEASURE_CURRENT(WM) = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
if(lastIinADCGainLevel != INSTRUCTION.ADCGainLevel){
IinADCGainControl(INSTRUCTION.ADCGainLevel);
record_flag = false;
static void IT_Plot(void)
{
static uint8_t ADCSwitch = 0;
void *wm = wm_get();
if (batteryCheck_flag) {
EliteADCBattery();
if (!batteryCheck_flag) {
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch = 2;
}
} else {
if (ADCSwitch == 0) { /**read Iin(buffer)**/
if (INSTRUCTION.AutoGainEnable) {
MEASURE_CURRENT(wm) = AutoGainReadIin(spi_ADC_rxbuf);
AutoGainChangeIin(MEASURE_CURRENT(wm));
} else {
ReadADCIin(spi_ADC_rxbuf);
MEASURE_CURRENT(wm) = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
if (lastIinADCGainLevel != INSTRUCTION.ADCGainLevel) {
IinADCGainControl(INSTRUCTION.ADCGainLevel);
record_flag = false;
}
}
if (record_flag == false) {
static int recordCount = 0;
recordCount++;
if (recordCount == 2) {
record_flag = true;
recordCount = 0;
}
} else {
InputNotify(NOTIFY_CURRENT, MEASURE_CURRENT(wm));
}
ADCSwitch++;
} else if (ADCSwitch == 1) { /**read Iin**/
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch++;
} else if(ADCSwitch == 2) { /**read Iin**/
ReadADCIin(spi_ADC_rxbuf);
ADCSwitch = 0;
}
}
}
static int32_t readVinVout(void *WM){
static void VT_Plot(void)
{
static uint8_t ADCSwitch = 0;
static int32_t VoltData;
void *wm = wm_get();
if(MEASURE_SWITCH(WM) == 0x01 || MEASURE_SWITCH(WM) == 0x02){
if(INSTRUCTION.VinAutoGainEnable){
MEASURE_VIN(WM) = AutoGainReadVin(spi_ADC_rxbuf);
AutoGainChangeVin(MEASURE_VIN(WM));
}else{
ReadADCVolt(MEASURE_SWITCH(WM));
MEASURE_VIN(WM) = DecodeADCValue(INSTRUCTION.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
if(lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel){
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
record_flag = false;
if (batteryCheck_flag) {
EliteADCBattery();
if (!batteryCheck_flag) {
ReadADCVolt(MEASURE_SWITCH(wm));
ADCSwitch = 2;
}
} else {
if (ADCSwitch == 0) { /**read V(buffer)**/
if (MEASURE_SWITCH(wm) == 0x01 || MEASURE_SWITCH(wm) == 0x02) {
if (INSTRUCTION.VinAutoGainEnable) {
MEASURE_VIN(wm) = AutoGainReadVin(spi_ADC_rxbuf);
AutoGainChangeVin(MEASURE_VIN(wm));
} else {
ReadADCVolt(MEASURE_SWITCH(wm));
MEASURE_VIN(wm) = DecodeADCValue(INSTRUCTION.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
if (lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel) {
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
record_flag = false;
}
}
VoltData = MEASURE_VIN(wm);
} else if (MEASURE_SWITCH(wm) == 0x00) {
ReadADCVolt(MEASURE_SWITCH(wm));
MEASURE_VOUT(wm) = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
VoltData = MEASURE_VOUT(wm);
}
if (record_flag == false) {
static int recordCount = 0;
recordCount++;
if (recordCount == 2) {
record_flag = true;
recordCount = 0;
}
} else {
InputNotify(NOTIFY_VOLT, VoltData);
}
ADCSwitch++;
} else if (ADCSwitch == 1) { /**read V**/
ReadADCVolt(MEASURE_SWITCH(wm));
ADCSwitch++;
} else if (ADCSwitch == 2) { /**read V**/
ReadADCVolt(MEASURE_SWITCH(wm));
ADCSwitch = 0;
}
VoltData = MEASURE_VIN(WM);
}else if(MEASURE_SWITCH(WM) == 0x00){
ReadADCVolt(MEASURE_SWITCH(WM));
MEASURE_VOUT(WM) = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
VoltData = MEASURE_VOUT(WM);
}
return VoltData;
}
static void cali_IT_plot(void *WM) {
static void cali_IT_plot(void) {
void *wm = wm_get();
static uint8_t ADCSwitch = 0;
static int32_t ADCValueSUM = 0;
int32_t ADCValueAVG = 0;
@@ -349,10 +359,10 @@ static void cali_IT_plot(void *WM) {
if(ADCSwitch == 0){ /**read Iin(buffer)**/
if(INSTRUCTION.AutoGainEnable){
MEASURE_CURRENT(WM) = 0xFFFF;
MEASURE_CURRENT(wm) = 0xFFFF;
}else{
ReadADCIin(spi_ADC_rxbuf);
MEASURE_CURRENT(WM) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
MEASURE_CURRENT(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
if(lastIinADCGainLevel != INSTRUCTION.ADCGainLevel){
IinADCGainControl(INSTRUCTION.ADCGainLevel);
record_flag = false;
@@ -393,8 +403,8 @@ static void cali_IT_plot(void *WM) {
ModeLED(NO_EVENT);
}else{
cali_count++;
ADCValueSUM = ADCValueSUM + MEASURE_CURRENT(WM);
InputNotify(NOTIFY_CURRENT, MEASURE_CURRENT(WM));
ADCValueSUM = ADCValueSUM + MEASURE_CURRENT(wm);
InputNotify(NOTIFY_CURRENT, MEASURE_CURRENT(wm));
InputNotify(NOTIFY_VOLT, ADCValueSUM);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
}
@@ -412,7 +422,9 @@ static void cali_IT_plot(void *WM) {
}
}
static void cali_VT_plot(void *WM) {
static void cali_VT_plot(void) {
void *wm = wm_get();
static uint8_t ADCSwitch = 0;
static int32_t VoltData = 0;
static int32_t ADCValueSUM = 0;
@@ -420,19 +432,19 @@ static void cali_VT_plot(void *WM) {
static uint16_t cali_count_max = 1000;
if(ADCSwitch == 0){ /**read Iin(buffer)**/
if(MEASURE_SWITCH(WM) == 0x01 || MEASURE_SWITCH(WM) == 0x02){
if(MEASURE_SWITCH(wm) == 0x01 || MEASURE_SWITCH(wm) == 0x02){
if(INSTRUCTION.VinAutoGainEnable){
MEASURE_VIN(WM) = 0xFFFF;
MEASURE_VIN(wm) = 0xFFFF;
}else{
ReadADCVolt(MEASURE_SWITCH(WM));
MEASURE_VIN(WM) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
ReadADCVolt(MEASURE_SWITCH(wm));
MEASURE_VIN(wm) = (int32_t) (spi_ADC_rxbuf[0] << 8) | (int32_t) (spi_ADC_rxbuf[1]);
if(lastVinADCGainLevel != INSTRUCTION.VinADCGainLevel){
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
record_flag = false;
}
}
VoltData = MEASURE_VIN(WM);
VoltData = MEASURE_VIN(wm);
}
if(INSTRUCTION.VinADCGainLevel == 0) {
@@ -470,21 +482,20 @@ static void cali_VT_plot(void *WM) {
ModeLED(NO_EVENT);
}else{
cali_count++;
ADCValueSUM = ADCValueSUM + MEASURE_VIN(WM);
InputNotify(NOTIFY_VOLT, MEASURE_VIN(WM));
ADCValueSUM = ADCValueSUM + MEASURE_VIN(wm);
InputNotify(NOTIFY_VOLT, MEASURE_VIN(wm));
InputNotify(NOTIFY_CURRENT, ADCValueSUM);
InputNotify(NOTIFY_IMPEDANCE, (int32_t)cali_count);
}
}
ADCSwitch++;
}
else if(ADCSwitch == 1){ /**read v**/
ReadADCVolt(MEASURE_SWITCH(WM));
ReadADCVolt(MEASURE_SWITCH(wm));
ADCSwitch++;
}
else if(ADCSwitch == 2){ /**read v**/
ReadADCVolt(MEASURE_SWITCH(WM));
ReadADCVolt(MEASURE_SWITCH(wm));
ADCSwitch = 0;
}
}
@@ -595,23 +595,23 @@ static bool If10Von = false;
static void TurnOn10V();
// periodic event control
static void EliteADCControl(void *WM);
static void EliteVscanControl(void *WM);
static void EliteADCControl(void);
static void EliteVscanControl(void);
static void EliteDone();
//mode (Vset)
static void LSV_Vscan(void *WM);
static void CVSCAN_Vscan(void *WM);
static void CV3_Vscan(void *WM);
static void CC_Vscan(void *WM);
static void CC_Vscan(void);
//mode (DAC)
static void DACenable(void *WorkModeData, int32_t VoltData, uint8_t afterRead);
static uint16_t OneWayVoltScan();
static void DACenable(uint8_t afterRead);
static void OneWayVoltScan();
static uint16_t CV3Curve(void *WM);
static uint16_t LSVCurve(void *WM);
static uint16_t CVSCANCurve(void *WM);
static void PULSE_Vscan(void *WM);
static void PULSE_Vscan(void);
//mode (notify)
static void initDATBuf();
@@ -752,14 +752,15 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case ZT_CURVE: {
case RT_CURVE: {
ModeLED(WORKING);
PIN15_setOutputValue(HIGH_Z_MODE, 1); // 1 => close high_z mode
INSTRUCTION.eliteFxn = ZT_CURVE;
INSTRUCTION.eliteFxn = RT_CURVE;
INSTRUCTION.notifyRate = (uint32_t)INSTRUCTION.sampleRate;
INSTRUCTION.sampleRate = 15;
INSTRUCTION.VsetRate = 100;
INSTRUCTION.VoltConstant = 25000 + 5000;
INSTRUCTION.Ve1 = 25000 + 5000;
INSTRUCTION.Vinit = (int32_t)INSTRUCTION.Ve1;
INSTRUCTION.VoViSwitch = 0x01;
// TODO: input to json
@@ -772,7 +773,7 @@ static void update_ZM_instruction(uint8 *ins) {
// end
if(INSTRUCTION.VoltConstant < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.VoltConstant > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
if(INSTRUCTION.Ve1 < DAC_VOUT_GAIN_LARGE_BOUNDARY_USERCODE && INSTRUCTION.Ve1 > DAC_VOUT_GAIN_LARGE_BOUNDARY1_USERCODE){
INSTRUCTION.VoutGainLevel = VOUT_GAIN_15K;
} else {
INSTRUCTION.VoutGainLevel = VOUT_GAIN_240K;
@@ -22,7 +22,7 @@
#include "EliteWorkData.h"
#include <driverlib/aon_batmon.h>
static void SimpleBLEPeripheral_performPeriodicTask(void *WM);
static void SimpleBLEPeripheral_performPeriodicTask(void);
static void SimpleBLEPeripheral_clockHandler(UArg arg) {
// Store the event.
@@ -81,7 +81,7 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
(INSTRUCTION.eliteFxn == CV_CURVE) || \
(INSTRUCTION.eliteFxn == IT_CURVE) || \
(INSTRUCTION.eliteFxn == VT_CURVE) || \
(INSTRUCTION.eliteFxn == ZT_CURVE) || \
(INSTRUCTION.eliteFxn == RT_CURVE) || \
(INSTRUCTION.eliteFxn == CONSTANT_CURRENT) || \
(INSTRUCTION.eliteFxn == CYCLIC_VOLTAMMETRY) || \
(INSTRUCTION.eliteFxn == LINEAR_SWEEP_VOLTAMMETRY) || \
@@ -106,8 +106,8 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
*
* @return None.
*/
static void SimpleBLEPeripheral_performPeriodicTask(void *WM) {
if ( IsPeriodicMode() ){
static void SimpleBLEPeripheral_performPeriodicTask(void) {
if (IsPeriodicMode()) {
/** Periodic Event **/
// Default working flow is vscan -> ADC read -> send notify
// We will need a flag to control vscan, ADC and notify
@@ -157,7 +157,7 @@ static void SimpleBLEPeripheral_performPeriodicTask(void *WM) {
GPT.VscanRateCounter -= INSTRUCTION.VsetRate * GPT.GptimerMultiple; //To get right time
vscan_flag = true;
if(vscan_flag){
EliteVscanControl(WM);
EliteVscanControl();
vscan_flag = false;
}
}
@@ -181,7 +181,7 @@ static void SimpleBLEPeripheral_performPeriodicTask(void *WM) {
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
ADC_flag = true;
if(ADC_flag){
EliteADCControl(WM);
EliteADCControl();
ADC_flag = false;
}
}
@@ -203,168 +203,161 @@ static void SimpleBLEPeripheral_performPeriodicTask(void *WM) {
// EliteDone();
}
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
GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
GPT.GptimerCounter0 = GPT.GptimerCounter;
if(EliteWorkReset){
InitEliteGPtimer();
EliteWorkReset = false;
batteryADC_flag = false;
record_flag = true;
firstTimeReset = true;
//pulsemode variable
stiFirstTime = true;
VinADCGainControl(INSTRUCTION.VinADCGainLevel);
IinADCGainControl(INSTRUCTION.ADCGainLevel);
VoutGainControl(INSTRUCTION.VoutGainLevel);
if (Ve1MatchVe2Mode()) {
if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.Ve1));
PeriodicEvent = false;
ModeLED(NO_EVENT);
}
} else if (INSTRUCTION.eliteFxn == PULSE_MODE) {
if(!megaStiEnable){
PeriodicEvent = false;
ModeLED(NO_EVENT);
}
}
}
GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
if(leadTimeReset && GPT.LeadTimeCounter <= 2000){
vscanReset = true;
}else{
if(notifyFirst_flag){
GPT.NotifyCounter = INSTRUCTION.notifyRate - 20;
notifyFirst_flag = false;
}
vscanReset = false;
leadTimeReset = false;
}
//vscan counter
GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
//pulse mode counter
GPT.StiCounter = GPT.StiCounter + GPT.DeltaGptimerCounter;
if (vscanReset) {
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
//vscanReset = false;
}else{
if (megaStiEnable) {
PULSE_Vscan(WM);
}
}
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate){
// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate * 2){
// GPT.GptimerMultiple = GPT.VscanRateCounter / INSTRUCTION.VsetRate;
// }else{
// GPT.GptimerMultiple = 1;
// }
// GPT.VscanRateCounter -= INSTRUCTION.VsetRate * GPT.GptimerMultiple; //To get right time
// vscan_flag = true;
// if(vscan_flag){
// EliteVscanControl(WM);
// vscan_flag = false;
// 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
//
// GPT.DeltaGptimerCounter = GPT.GptimerCounter - GPT.GptimerCounter0;
// GPT.GptimerCounter0 = GPT.GptimerCounter;
//
// if(EliteWorkReset){
// InitEliteGPtimer();
// EliteWorkReset = false;
// batteryADC_flag = false;
// record_flag = true;
// firstTimeReset = true;
// //pulsemode variable
// stiFirstTime = true;
// VinADCGainControl(INSTRUCTION.VinADCGainLevel);
// IinADCGainControl(INSTRUCTION.ADCGainLevel);
// VoutGainControl(INSTRUCTION.VoutGainLevel);
// if (Ve1MatchVe2Mode()) {
// if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) {
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, INSTRUCTION.Ve1));
// PeriodicEvent = false;
// ModeLED(NO_EVENT);
// }
// } else if (INSTRUCTION.eliteFxn == PULSE_MODE) {
// if(!megaStiEnable){
// PeriodicEvent = false;
// ModeLED(NO_EVENT);
// }
// }
// }
//battery counter
GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
if(GPT.BatteryCheckCounter >= 50000){
GPT.BatteryCheckCounter -= 50000; //To get right time
batteryCheck_flag = true;
}
uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
if( bat < 768 && bat > 20){
PIN15_setOutputValue(enable_5v, 0);
}
//ADC counter
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
if(GPT.SampleRateCounter >= INSTRUCTION.sampleRate){
GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
ADC_flag = true;
if(ADC_flag){
EliteADCControl(WM);
ADC_flag = false;
}
}
//Notify counter(Notify control, check if we need to send notify)
//please don't put Notify counter before ADC counter, maybe get wrong data
GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
if(GPT.NotifyCounter >= INSTRUCTION.notifyRate){
GPT.NotifyCounter -= INSTRUCTION.notifyRate; //To get right time
notify_flag = true;
if(vscanReset){
notify_flag = false;
}
if(notify_flag){
SendNotify();
notify_flag = false;
}
}
// EliteDone();
}
// else if(INSTRUCTION.eliteFxn == VOLT_OUTPUT){
// VoutGainControl(INSTRUCTION.VoutGainLevel);
// WM->VO->_Vset = INSTRUCTION.VoltConstant;
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, WM->VO->_Vset)); //UserCode -> DAC code -> DAC out
// FreeWorkMode(WM);
//
//
// GPT.LeadTimeCounter = GPT.LeadTimeCounter + GPT.DeltaGptimerCounter;
// if(leadTimeReset && GPT.LeadTimeCounter <= 2000){
// vscanReset = true;
// }else{
// if(notifyFirst_flag){
// GPT.NotifyCounter = INSTRUCTION.notifyRate - 20;
// notifyFirst_flag = false;
// }
// vscanReset = false;
// leadTimeReset = false;
// }
//
// //vscan counter
// GPT.VscanRateCounter = GPT.VscanRateCounter + GPT.DeltaGptimerCounter;
// //pulse mode counter
// GPT.StiCounter = GPT.StiCounter + GPT.DeltaGptimerCounter;
// if (vscanReset) {
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoutGainLevel, 25000));
// //vscanReset = false;
// }else{
// if (megaStiEnable) {
// PULSE_Vscan();
// }
// }
//
//// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate){
//// if(GPT.VscanRateCounter >= INSTRUCTION.VsetRate * 2){
//// GPT.GptimerMultiple = GPT.VscanRateCounter / INSTRUCTION.VsetRate;
//// }else{
//// GPT.GptimerMultiple = 1;
//// }
//// GPT.VscanRateCounter -= INSTRUCTION.VsetRate * GPT.GptimerMultiple; //To get right time
//// vscan_flag = true;
//// if(vscan_flag){
//// EliteVscanControl();
//// vscan_flag = false;
//// }
//// }
//
// //battery counter
// GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
// GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
// if(GPT.BatteryCheckCounter >= 50000){
// GPT.BatteryCheckCounter -= 50000; //To get right time
// batteryCheck_flag = true;
// }
//
// uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
// if( bat < 768 && bat > 20){
// PIN15_setOutputValue(enable_5v, 0);
// }
//
// //ADC counter
// GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
// if(GPT.SampleRateCounter >= INSTRUCTION.sampleRate){
// GPT.SampleRateCounter = 0; //To get right data, ADC must be delay 1.5ms
// ADC_flag = true;
// if(ADC_flag){
// EliteADCControl();
// ADC_flag = false;
// }
// }
//
// //Notify counter(Notify control, check if we need to send notify)
// //please don't put Notify counter before ADC counter, maybe get wrong data
// GPT.NotifyCounter = GPT.NotifyCounter + GPT.DeltaGptimerCounter;
// if(GPT.NotifyCounter >= INSTRUCTION.notifyRate){
// GPT.NotifyCounter -= INSTRUCTION.notifyRate; //To get right time
// notify_flag = true;
// if(vscanReset){
// notify_flag = false;
// }
// if(notify_flag){
// SendNotify();
// notify_flag = false;
// }
// }
//
// // EliteDone();
// }
// else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
// DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
// wm_deinit();
// PeriodicEvent = false;
// }
else if(INSTRUCTION.eliteFxn == CALI_DAC_MODE){
DAC_outputV(INSTRUCTION.VoltConstant); //UserCode -> DAC code -> DAC out
FreeWorkMode(&WM);
PeriodicEvent = false;
}
else{
// InitFlag();
}
}
static void EliteADCControl(void *WM)
static void EliteADCControl(void)
{
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:
case CV_CURVE:
case ZT_CURVE:
case CONSTANT_CURRENT:
case CYCLIC_VOLTAMMETRY:
case LINEAR_SWEEP_VOLTAMMETRY:
case CONSTANT_VSCAN:
case PULSE_MODE:
// case IV_CURVE:
// case CV_CURVE:
case RT_CURVE:
// case CONSTANT_CURRENT:
// case CYCLIC_VOLTAMMETRY:
// case LINEAR_SWEEP_VOLTAMMETRY:
// case CONSTANT_VSCAN:
// case PULSE_MODE:
case VOLT_OUTPUT:
CC_Plot(WM);
CC_Plot();
break;
case IT_CURVE:
IT_Plot(WM);
IT_Plot();
break;
case VT_CURVE:
VT_Plot(WM);
VT_Plot();
break;
case CALI_ADC_MODE:
if (INSTRUCTION.AdcChannel == IIN_ADC) {
cali_IT_plot(WM);
} else if (INSTRUCTION.AdcChannel == VIN_ADC) {
cali_VT_plot(WM);
}
break;
// case CALI_ADC_MODE:
// if (INSTRUCTION.AdcChannel == IIN_ADC) {
// cali_IT_plot();
// } else if (INSTRUCTION.AdcChannel == VIN_ADC) {
// cali_VT_plot();
// }
// break;
default:
break;
@@ -380,44 +373,44 @@ static void EliteDone() {
}
}
static void EliteVscanControl(void *WM) {
static void EliteVscanControl(void) {
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:{
IV_Vscan(WM);
// case IV_CURVE:{
// IV_Vscan(WM);
// break;
// }
// case CV_CURVE:{
// CV_Vscan(WM);
// break;
// }
case VOLT_OUTPUT:
VOUT_Vscan();
break;
}
case CV_CURVE:{
CV_Vscan(WM);
case RT_CURVE:
ZT_Vscan();
break;
}
case VOLT_OUTPUT:{
VOUT_Vscan(WM);
break;
}
case ZT_CURVE:{
ZT_Vscan(WM);
break;
}
case CYCLIC_VOLTAMMETRY:{
CV3_Vscan(WM);
break;
}
case CONSTANT_CURRENT:{
CC_Vscan(WM);
break;
}
case LINEAR_SWEEP_VOLTAMMETRY:{
LSV_Vscan(WM);
break;
}
case CONSTANT_VSCAN:{
CVSCAN_Vscan(WM);
break;
}
case PULSE_MODE:{
// PULSE_Vscan(WM);
break;
}
// case CYCLIC_VOLTAMMETRY:{
// CV3_Vscan(WM);
// break;
// }
// case CONSTANT_CURRENT:{
// CC_Vscan();
// break;
// }
// case LINEAR_SWEEP_VOLTAMMETRY:{
// LSV_Vscan(WM);
// break;
// }
// case CONSTANT_VSCAN:{
// CVSCAN_Vscan(WM);
// break;
// }
// case PULSE_MODE:{
//// PULSE_Vscan();
// break;
// }
default:{
break;
}
@@ -547,7 +547,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
// Initialize application
SimpleBLEPeripheral_init();
ZM_init();
void *WorkMode = NULL;
// void *WorkMode = NULL;
// init DAC, set output ~= 0 V
@@ -614,6 +614,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
}
}
}
if(events & SBP_PERIODIC_EVT){
events &= ~SBP_PERIODIC_EVT;
if (!PeriodicEvent) { // if there is no periodic event
@@ -633,7 +634,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
measureBat();
}
if(Free_Work_Mode){
FreeWorkMode(&WorkMode);
wm_deinit();
InitEliteInstruction();
Free_Work_Mode = false;
}
@@ -643,12 +644,12 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
}
else { // if there is periodic event
if(InitPeriodicEvent){
InitWorkMode(&WorkMode);
wm_init();
InitPeriodicEvent = false;
}
// Perform periodic application task
SimpleBLEPeripheral_performPeriodicTask(WorkMode);
SimpleBLEPeripheral_performPeriodicTask();
key = PIN_getInputValue(switch_on);
EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650
}