Elite 1.4-re IUC to real nA/pA
This commit is contained in:
+14
-1
@@ -25,7 +25,7 @@ struct CURRENT_USER_CODE{
|
||||
|
||||
static int32_t CCModeReadCurrent(){
|
||||
int32_t Real_Current = 0;
|
||||
CCModeReset = 0; //
|
||||
CCModeReset = 0; // This flag will control DAC working
|
||||
|
||||
CCCurrent2IUC();
|
||||
// read ADC current
|
||||
@@ -41,9 +41,14 @@ static int32_t CCModeReadCurrent(){
|
||||
|
||||
// decode ADC value and put it into notify buffer
|
||||
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
return Real_Current;
|
||||
}
|
||||
|
||||
static int32_t CCModeOutputDAC(){
|
||||
if(CCModeReset){
|
||||
// DAC should not work now
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -108,4 +113,12 @@ static void CCCurrent2IUC(){
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t IUC2RealnA(){
|
||||
|
||||
}
|
||||
|
||||
static int32_t IUC2RealpA{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+10
-10
@@ -9,7 +9,7 @@ static uint16_t SWVCurve() {
|
||||
static bool direction_up;
|
||||
|
||||
// reset origin volt at the begin
|
||||
if (DACreset) {
|
||||
if (DACReset) {
|
||||
Volt = INSTRUCTION.VoltOrigin;
|
||||
outputV = INSTRUCTION.VoltOrigin;
|
||||
if (INSTRUCTION.VoltOrigin < INSTRUCTION.VoltFinal)
|
||||
@@ -17,7 +17,7 @@ static uint16_t SWVCurve() {
|
||||
else
|
||||
direction_up = false;
|
||||
counter = 1;
|
||||
DACreset = false;
|
||||
DACReset = false;
|
||||
}
|
||||
|
||||
if (counter == 2 * PulseWidth)
|
||||
@@ -34,7 +34,7 @@ static uint16_t SWVCurve() {
|
||||
// check if we reach the final volt
|
||||
if ((outputV >= INSTRUCTION.VoltFinal && direction_up) || (outputV <= INSTRUCTION.VoltFinal && !direction_up)) {
|
||||
PeriodicEvent = false;
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
}
|
||||
|
||||
// prepare the next output volt
|
||||
@@ -65,7 +65,7 @@ static uint16_t DPVCurve() {
|
||||
static bool direction_up;
|
||||
|
||||
// reset origin volt at the begin
|
||||
if (DACreset) {
|
||||
if (DACReset) {
|
||||
if (INSTRUCTION.VoltOrigin < INSTRUCTION.VoltFinal)
|
||||
direction_up = true;
|
||||
else
|
||||
@@ -78,7 +78,7 @@ static uint16_t DPVCurve() {
|
||||
Volt2 = INSTRUCTION.VoltOrigin - Amplitude;
|
||||
|
||||
counter = 1;
|
||||
DACreset = false;
|
||||
DACReset = false;
|
||||
}
|
||||
|
||||
if (counter == PulsePeriod)
|
||||
@@ -101,7 +101,7 @@ static uint16_t DPVCurve() {
|
||||
// check if we reach the final volt
|
||||
if (((outputV >= INSTRUCTION.VoltFinal) && direction_up) || ((outputV <= INSTRUCTION.VoltFinal) && !direction_up)) {
|
||||
PeriodicEvent = false;
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
}
|
||||
|
||||
// check overflow/underflow and prepare for next output
|
||||
@@ -140,7 +140,7 @@ static uint16_t CVCurve() {
|
||||
static bool current_direction_up;
|
||||
|
||||
// reset origin volt at the begin
|
||||
if (DACreset) {
|
||||
if (DACReset) {
|
||||
outputV = INSTRUCTION.VoltOrigin;
|
||||
if (INSTRUCTION.VoltFinal > INSTRUCTION.VoltOrigin) {
|
||||
direction_up = true;
|
||||
@@ -151,7 +151,7 @@ static uint16_t CVCurve() {
|
||||
}
|
||||
ramp0 = (uint8_t)(INSTRUCTION.VoltOrigin & 0x00FF); // right byte
|
||||
ramp1 = (uint8_t)((INSTRUCTION.VoltOrigin >> 8) & 0x00FF); // left byte
|
||||
DACreset = false;
|
||||
DACReset = false;
|
||||
}
|
||||
|
||||
// output a certain volt
|
||||
@@ -164,7 +164,7 @@ static uint16_t CVCurve() {
|
||||
current_direction_up = true;
|
||||
if (INSTRUCTION.CycleNumber == 0) {
|
||||
PeriodicEvent = false; // periodic event end
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
}
|
||||
INSTRUCTION.CycleNumber--;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ static uint16_t CVCurve() {
|
||||
current_direction_up = false;
|
||||
if (INSTRUCTION.CycleNumber == 0) {
|
||||
PeriodicEvent = false; // periodic event end
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
}
|
||||
INSTRUCTION.CycleNumber--;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
#ifndef EliteDAC
|
||||
#define EliteDAC
|
||||
|
||||
static bool DACreset = true;
|
||||
static bool DACReset = true;
|
||||
|
||||
|
||||
//#ifdef ELITE_VERSION_1_3
|
||||
|
||||
+1
@@ -173,6 +173,7 @@ static int32_t DecodeADCVolt(uint16_t ADC_measure){
|
||||
|
||||
// this function turn ADC measure value (0xXXXX) into real current
|
||||
// unit should be pA
|
||||
// if ADCGain is 200R => uint should be nA
|
||||
static int32_t DecodeADCCurrent(uint8_t ADCGain, uint16_t ADC_measure){
|
||||
int32_t ADCRealCurrent = 0;
|
||||
|
||||
|
||||
+4
-4
@@ -29,9 +29,9 @@ static uint16_t OneWayVoltScan() {
|
||||
static uint16_t DACOutCode;
|
||||
|
||||
// reset origin volt at the begin
|
||||
if (DACreset) {
|
||||
if (DACReset) {
|
||||
DACOutCode = INSTRUCTION.VoltOrigin;
|
||||
DACreset = false;
|
||||
DACReset = false;
|
||||
|
||||
// output VOLT_ORIGIN
|
||||
DAC_outputV(DACOutCode);
|
||||
@@ -47,7 +47,7 @@ static uint16_t OneWayVoltScan() {
|
||||
// end IV task if we reach INSTRUCTION.VoltFinal
|
||||
if (DACOutCode >= INSTRUCTION.VoltFinal) {
|
||||
PeriodicEvent = false;
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
}
|
||||
} else {
|
||||
// output the next output volt
|
||||
@@ -57,7 +57,7 @@ static uint16_t OneWayVoltScan() {
|
||||
// end IV task if we reach INSTRUCTION.VoltFinal
|
||||
if (DACOutCode <= INSTRUCTION.VoltFinal) {
|
||||
PeriodicEvent = false;
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -4,6 +4,8 @@
|
||||
|
||||
static void reset() {
|
||||
PeriodicEvent = false;
|
||||
DACReset = true;
|
||||
CCModeReset = 1;
|
||||
InitEliteInstruction();
|
||||
SampleRate_counter = 1;
|
||||
StepTimeCounter = 1;
|
||||
@@ -42,6 +44,8 @@ static void reset() {
|
||||
|
||||
static void Eliteinterrupt() {
|
||||
PeriodicEvent = false;
|
||||
DACReset = true;
|
||||
CCModeReset = 1;
|
||||
InitEliteInstruction();
|
||||
StepTimeCounter = 1;
|
||||
SampleRate_counter = 1;
|
||||
@@ -80,6 +84,8 @@ static void Eliteinterrupt() {
|
||||
|
||||
static void CleanBuffer() {
|
||||
PeriodicEvent = false;
|
||||
DACReset = true;
|
||||
CCModeReset = 1;
|
||||
InitEliteInstruction();
|
||||
SampleRate_counter = 1;
|
||||
StepTimeCounter = 1;
|
||||
|
||||
+7
-7
@@ -614,11 +614,13 @@ static int32_t ADCRealCurrent = 0;
|
||||
static long long ADCRealCurrent_long = 0;
|
||||
|
||||
// Constant Current Mode function
|
||||
static CCModeReset = 1;
|
||||
static uint8_t CCModeReset = 1;
|
||||
static int32_t CCModeReadCurrent();
|
||||
static int32_t CCModeOutputDAC();
|
||||
static void SetCCModeGain();
|
||||
static void CCCurrent2IUC();
|
||||
static int32_t IUC2RealnA();
|
||||
static int32_t IUC2RealpA();
|
||||
|
||||
// for DPVCurve SWVCurve
|
||||
static uint16_t Amplitude;
|
||||
@@ -694,8 +696,6 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
uint8_t oper = ins[1] & 0xF0; // this is don't care in RIS
|
||||
uint8_t data_length = ins[1] & 0x0F;
|
||||
|
||||
DACreset = true;
|
||||
|
||||
if (!If10Von) {
|
||||
// TurnOn10V();
|
||||
}
|
||||
@@ -707,7 +707,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
case IV_CURVE: {
|
||||
CleanBuffer();
|
||||
INSTRUCTION.eliteFxn = IV_CURVE;
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
INSTRUCTION.SampleRate = 10;
|
||||
|
||||
if (ins[3] | ins[4]) {
|
||||
@@ -733,7 +733,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
case DIFFERENTIAL_PULSE_VOLTAMMETRY: {
|
||||
CleanBuffer();
|
||||
INSTRUCTION.eliteFxn = DIFFERENTIAL_PULSE_VOLTAMMETRY;
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
|
||||
if (ins[3] | ins[4]) {
|
||||
INSTRUCTION.VoltOrigin = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
|
||||
@@ -768,7 +768,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
case SQUARE_WAVE_VOLTAMMETRY: {
|
||||
CleanBuffer();
|
||||
INSTRUCTION.eliteFxn = SQUARE_WAVE_VOLTAMMETRY;
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
|
||||
if (ins[3] | ins[4]) {
|
||||
INSTRUCTION.VoltOrigin = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
|
||||
@@ -799,7 +799,7 @@ static void update_ZM_instruction(uint8 *ins) {
|
||||
case CYCLIC_VOLTAMMETRY: {
|
||||
CleanBuffer();
|
||||
INSTRUCTION.eliteFxn = CYCLIC_VOLTAMMETRY;
|
||||
DACreset = true;
|
||||
DACReset = true;
|
||||
|
||||
if (ins[3] | ins[4]) {
|
||||
INSTRUCTION.VoltOrigin = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
|
||||
|
||||
Reference in New Issue
Block a user