From 0bc5b8bfb8ab4ec9639d1f0cc1d9a528bba830a3 Mon Sep 17 00:00:00 2001 From: YiChin Date: Fri, 10 Jul 2020 16:07:13 +0800 Subject: [PATCH] update CV3 LSV CA code (ADC) --- .../cc26xx/app/headstage/EliteCCMode.h | 30 +------ .../cc26xx/app/headstage/EliteCV3Mode.h | 18 ++-- .../cc26xx/app/headstage/EliteIVCurve.h | 85 ++++++++++++------- .../cc26xx/app/headstage/EliteZTcurve.h | 4 +- .../cc26xx/app/headstage/Elite_version.h | 4 +- .../cc26xx/app/headstage/headstage.h | 5 +- .../cc26xx/app/headstage/impedance_meter.h | 9 +- 7 files changed, 79 insertions(+), 76 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCCMode.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCCMode.h index 79624ca32..14050e56c 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCCMode.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCCMode.h @@ -11,32 +11,6 @@ * Real current value : -15.00000 ~ 15.00000 mA * => user code = 1500000 mapping to 0.00000 mA */ - -static uint16_t CCCurve(CCMode *CC){ - static uint16_t DACOutCode; - static int32_t Vout; - static int32_t DeltaVout; - - if(DACReset){ - Vout = Vset; - DACReset = false; - }else{ - DeltaVout = Vset - (Vout); - Vout = Vout + DeltaVout; - } - - INSTRUCTION.VoltConstant = Vout / 40000 + 25000; //5nV=>usercode - DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant); - DAC_outputV(DACOutCode); - - int32_t RealV; - RealV = (int32_t)(Vout / 200); //[5nV] - InputNotify(NOTIFY_IMPEDANCE, RealV); - - - return DACOutCode; -} - static void CC_Plot(WorkMode *WorkModeData){ switch (INSTRUCTION.eliteFxn) { case IT_CURVE:{ @@ -93,7 +67,7 @@ static void CC_Plot(WorkMode *WorkModeData){ InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent); - DACenable(WorkModeData, VoltData); + DACenable(WorkModeData, VoltData, AFTER_READ_I); ReadADCVolt(CURRENT_MODE->_VoViSwitch); ADCSwitch++; @@ -120,6 +94,8 @@ static void CC_Plot(WorkMode *WorkModeData){ InputNotify(NOTIFY_VOLT, VoltData); } + DACenable(WorkModeData, VoltData, AFTER_READ_V); + ReadCurrent(spi_ADC_rxbuf); ADCSwitch++; } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCV3Mode.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCV3Mode.h index 726c4b858..8bd3acad5 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCV3Mode.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCV3Mode.h @@ -41,9 +41,9 @@ static void CV3_Plot(CV3Mode *CV3){ ->_VoViSwitch : 0 read Vout volt ***********************************************/ - static uint8_t VoltCurrentSwitch = 0; + static uint8_t ADCSwitch = 0; - if(VoltCurrentSwitch == 0){ /**read Iin(buffer),read Vin**/ + if(ADCSwitch == 0){ /**read Iin(buffer),read Vin**/ // read current if(INSTRUCTION.AutoGainEnable){ CV3->_measureCurrent = AutoGainReadCurrent(spi_ADC_rxbuf); @@ -62,9 +62,9 @@ static void CV3_Plot(CV3Mode *CV3){ ReadVoutVolt(spi_ADC_rxbuf); } - VoltCurrentSwitch++; + ADCSwitch++; } - else if(VoltCurrentSwitch == 1){ /**read Vin**/ + else if(ADCSwitch == 1){ /**read Vin**/ // read Volt if(CV3->_VoViSwitch == 0x01){ ReadVolt(spi_ADC_rxbuf); @@ -72,9 +72,9 @@ static void CV3_Plot(CV3Mode *CV3){ ReadVoutVolt(spi_ADC_rxbuf); } - VoltCurrentSwitch++; + ADCSwitch++; } - else if(VoltCurrentSwitch == 2){ /**read Vin(buffer),read Iin**/ + else if(ADCSwitch == 2){ /**read Vin(buffer),read Iin**/ // read Volt if(CV3->_VoViSwitch == 0x01){ ReadVolt(spi_ADC_rxbuf);// read vin volt @@ -89,13 +89,13 @@ static void CV3_Plot(CV3Mode *CV3){ // read current ReadCurrent(spi_ADC_rxbuf); - VoltCurrentSwitch++; + ADCSwitch++; } - else if(VoltCurrentSwitch == 3){ /**read Iin**/ + else if(ADCSwitch == 3){ /**read Iin**/ // read current ReadCurrent(spi_ADC_rxbuf); - VoltCurrentSwitch = 0; + ADCSwitch = 0; } } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteIVCurve.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteIVCurve.h index 420dc2413..6908d28f7 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteIVCurve.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteIVCurve.h @@ -27,37 +27,64 @@ static uint16_t VoltScan(WorkMode *WorkModeData) { return Voltage; } -static void DACenable(WorkMode *WorkModeData,int32_t VoltData){ - switch (INSTRUCTION.eliteFxn) { - case IV_CURVE: - case CV_CURVE:{ - OneWayVoltScan(); - break; +static void DACenable(WorkMode *WorkModeData, int32_t VoltData ,uint8_t afterRead){ + if(afterRead == AFTER_READ_I){ + switch (INSTRUCTION.eliteFxn) { + case IV_CURVE: + case CV_CURVE:{ + break; + } + case ZT_CURVE:{ +// CalcuResistance(WorkModeData->RT, VoltData); + break; + } + case CONSTANT_CURRENT:{ + CC_Vscan(WorkModeData->CC); + OneWayVoltScan(); + break; + } + case IT_CURVE: + case VT_CURVE: + case CYCLIC_VOLTAMMETRY: + case LINEAR_SWEEP_VOLTAMMETRY: + case CONSTANT_VSCAN:{ + break; + } + default:{ + break; + } } - case ZT_CURVE:{ - CalcuResistance(WorkModeData->RT, VoltData); - break; - } - case IT_CURVE: - case VT_CURVE:{ - break; - } - case CONSTANT_CURRENT:{ - CC_Vscan(WorkModeData->CC); - OneWayVoltScan(); - break; - } - case CYCLIC_VOLTAMMETRY:{ - break; - } - case LINEAR_SWEEP_VOLTAMMETRY:{ - break; - } - case CONSTANT_VSCAN:{ - break; - } - default:{ + }else if(afterRead == AFTER_READ_V){ + switch (INSTRUCTION.eliteFxn) { + case IV_CURVE: + case CV_CURVE:{ + OneWayVoltScan(); + break; + } + case ZT_CURVE:{ + CalcuResistance(WorkModeData->RT, VoltData); break; + } + case IT_CURVE: + case VT_CURVE: + case CONSTANT_CURRENT:{ + break; + } + case CYCLIC_VOLTAMMETRY:{ + CV3Curve(WorkModeData->CV3); + break; + } + case LINEAR_SWEEP_VOLTAMMETRY:{ + LSVCurve(WorkModeData->LSV); + break; + } + case CONSTANT_VSCAN:{ + CVSCANCurve(WorkModeData->CVSCAN); + break; + } + default:{ + break; + } } } } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteZTcurve.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteZTcurve.h index b1db0d3c2..c790b1d5a 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteZTcurve.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteZTcurve.h @@ -64,7 +64,7 @@ static void ZT_Plot(WorkMode *WorkModeData) { InputNotify(NOTIFY_CURRENT, CURRENT_MODE->_measureCurrent); - DACenable(WorkModeData, VoltData); + DACenable(WorkModeData, VoltData, AFTER_READ_I); ReadADCVolt(CURRENT_MODE->_VoViSwitch); ADCSwitch++; @@ -85,6 +85,8 @@ static void ZT_Plot(WorkMode *WorkModeData) { InputNotify(NOTIFY_VOLT, VoltData); + DACenable(WorkModeData, VoltData, AFTER_READ_V); + ReadCurrent(spi_ADC_rxbuf); ADCSwitch++; } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h index fbbdcee0f..a7f8dc2d4 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_version.h @@ -5,8 +5,8 @@ #define VERSION_DATE_YEAR 20 #define VERSION_DATE_MONTH 7 #define VERSION_DATE_DAY 10 -#define VERSION_DATE_HOUR 14 -#define VERSION_DATE_MINUTE 59 +#define VERSION_DATE_HOUR 16 +#define VERSION_DATE_MINUTE 7 // this is NOT the version hash !! // it's the last version hash diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h index 906e9a0fa..c9aca4404 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage.h @@ -496,6 +496,8 @@ characteristic change event #define VMAX(v1,v2) ((v1 >= v2) ? v1 : v2) #define VMIN(v1,v2) ((v1 < v2) ? v1 : v2) #define VDIRECTION(v1,v2) ((v1 > v2) ? 0 : 1) +#define AFTER_READ_I 0 +#define AFTER_READ_V 1 #include "EliteWorkData.h" /** @@ -654,10 +656,9 @@ static void CV3_Vscan(CV3Mode *CV3); static void CC_Vscan(CCMode *CC); //mode (DAC) -static void DACenable(WorkMode *WorkModeData,int32_t VoltData); +static void DACenable(WorkMode *WorkModeData, int32_t VoltData, uint8_t afterRead); static uint16_t OneWayVoltScan(); static void CalcuResistance(RTMode *RT, int32_t VoltData); -static uint16_t CCCurve(CCMode *CC); static uint16_t CV3Curve(CV3Mode *CV3); static uint16_t LSVCurve(LSVMode *LSV); static uint16_t CVSCANCurve(CVSCANMode *CVSCAN); diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h index 30b935739..a767748bf 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/impedance_meter.h @@ -239,18 +239,15 @@ static void EliteADCControl(WorkMode *WorkModeData) { break; } case CYCLIC_VOLTAMMETRY:{ - CV3_Plot(WorkModeData->CV3); + CC_Plot(WorkModeData); break; } case LINEAR_SWEEP_VOLTAMMETRY:{ - if (INSTRUCTION.Ve1 == INSTRUCTION.Ve2) { - PeriodicEvent = false; - } - LSV_Plot(WorkModeData->LSV); + CC_Plot(WorkModeData); break; } case CONSTANT_VSCAN:{ - CVSCAN_Plot(WorkModeData->CVSCAN); + CC_Plot(WorkModeData); break; } default:{