From 13efb6c32ae4746839ada42363e3782a04cab870 Mon Sep 17 00:00:00 2001 From: 105042004 Date: Fri, 1 Nov 2019 17:35:04 +0800 Subject: [PATCH 1/5] add limit to IVmode --- .../cc26xx/app/headstage/EliteITCurve.h | 33 +++++++++++++++++-- .../cc26xx/app/headstage/EliteWorkData.h | 6 ++++ .../cc26xx/app/headstage/impedance_meter.h | 6 ++-- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h index de96f6812..1d9131eb7 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h @@ -20,7 +20,24 @@ // return Real_Current; //} -static int32_t IT_Plot(ITMode *IT) { +static int32_t IT_Plot(WorkMode *WorkModeData) { + + switch (INSTRUCTION.eliteFxn) { + case IV_CURVE:{ + + #define CURRENT_MODE WorkModeData->IV + break; + } + case CV_CURVE:{ + #define CURRENT_MODE WorkModeData->CV + break; + } + case IT_CURVE:{ + #define CURRENT_MODE WorkModeData->IT + break; + } + } + // read ADC current int32_t Real_Current = 0; @@ -31,9 +48,18 @@ static int32_t IT_Plot(ITMode *IT) { ReadCurrent(spi_ADC_rxbuf); Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf); } - IT->SetMeasureData((struct Measure *) IT, Real_Current); - Real_Current = IT->GetMeasureData((struct Measure *) IT); + // IT->SetMeasureData((struct Measure *) IT, Real_Current); + // Real_Current = IT->GetMeasureData((struct Measure *) IT); + CURRENT_MODE->_MeasureData = Real_Current; + + + if(INSTRUCTION.eliteFxn == IV_CURVE){ + if(Real_Current > IT->_LimitValue){ + PeriodicEvent = false; //Real current exceed expected limit value, force stop + DACReset = true; + } + } NotifyCurrent[0] = (uint8_t) (Real_Current >> 24); NotifyCurrent[1] = (uint8_t) ((Real_Current & 0x00FF0000) >> 16); NotifyCurrent[2] = (uint8_t) ((Real_Current & 0x0000FF00) >> 8); @@ -42,4 +68,5 @@ static int32_t IT_Plot(ITMode *IT) { return Real_Current; } + #endif diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h index 043bcc8ee..c442679c9 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h @@ -115,6 +115,7 @@ int32_t _GetMeasureData(struct Measure *self){ /* IT Mode Data */ typedef struct _ITMode{ MEASURE; + LIMIT; }ITMode; ITMode * InitITMode(){ @@ -122,6 +123,11 @@ ITMode * InitITMode(){ ret->_MeasureData = 0; ret->SetMeasureData = &_SetMeasureData; ret->GetMeasureData = &_GetMeasureData; + + ret->_LimitValue = 0; + + ret->SetLimitValue = &_SetLimitValue; + ret->GetLimitValue = &_GetLimitValue; return ret; } /* End of IT Mode Data */ 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 9edba041c..20e003e74 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 @@ -179,15 +179,15 @@ static void EliteADCControl(WorkMode *WorkModeData) { if (SampleRate_counter == INSTRUCTION.SampleRate - 1) { switch (INSTRUCTION.eliteFxn) { case IV_CURVE:{ - IT_Plot(WorkModeData->IT); + IT_Plot(WorkModeData); break; } case CV_CURVE:{ - IT_Plot(WorkModeData->IT); + IT_Plot(WorkModeData); break; } case IT_CURVE:{ - IT_Plot(WorkModeData->IT); + IT_Plot(WorkModeData); break; } case VT_CURVE:{ From d3f6a6521a7a427323849e21642beef274fe651a Mon Sep 17 00:00:00 2001 From: YiChin Date: Fri, 1 Nov 2019 18:23:58 +0800 Subject: [PATCH 2/5] fix ITmode bug --- .../cc26xx/app/headstage/EliteITCurve.h | 2 +- .../cc26xx/app/headstage/EliteWorkData.h | 19 ++++++++++--------- .../cc26xx/app/headstage/headstage.h | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h index 1d9131eb7..588ea5d88 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h @@ -55,7 +55,7 @@ static int32_t IT_Plot(WorkMode *WorkModeData) { if(INSTRUCTION.eliteFxn == IV_CURVE){ - if(Real_Current > IT->_LimitValue){ + if(Real_Current > CURRENT_MODE->_LimitValue){ PeriodicEvent = false; //Real current exceed expected limit value, force stop DACReset = true; } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h index c442679c9..06499c2d7 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h @@ -112,6 +112,16 @@ int32_t _GetMeasureData(struct Measure *self){ return self->_MeasureData; } + +/**** Limit Mode ****/ +//LimitValue +void _SetLimitValue(struct Limit *self, uint16_t LimitValue){ + self->_LimitValue = LimitValue; +} +uint16_t _GetLimitValue(struct Limit *self){ + return self->_LimitValue; +} + /* IT Mode Data */ typedef struct _ITMode{ MEASURE; @@ -197,15 +207,6 @@ uint16_t _GetCycleNumber(struct VoltOutPara *self){ return self->_CycleNumber; } -/**** Limit Mode ****/ -//LimitValue -void _SetLimitValue(struct Limit *self, uint16_t LimitValue){ - self->_LimitValue = LimitValue; -} -uint16_t _GetLimitValue(struct Limit *self){ - return self->_LimitValue; -} - /* VoltOut Mode Data */ typedef struct _VoltOutMode{ 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 f57ac4160..f83de9e60 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 @@ -638,7 +638,7 @@ static void DACCode2Real2Notify(uint16_t DACcode); // send notify voltage a //static void VOLT_OUTPUT(); static void ZT_Plot(RTMode *RT); static void VT_Plot(VTMode *VT); -static int32_t IT_Plot(ITMode *IT); +static int32_t IT_PlotIT_Plot(WorkMode *WorkModeData); // the following fxn do the same thing // IVCurve_T is called if Vorigin > Vfinal, vice versa From e9b5414ab09abf13c0f65c98ec834faa8fd55a98 Mon Sep 17 00:00:00 2001 From: 105042004 Date: Fri, 1 Nov 2019 18:28:06 +0800 Subject: [PATCH 3/5] set _LimitVlaue to 1e5 --- .../cc26xx/app/headstage/EliteWorkData.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h index 06499c2d7..98941c421 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteWorkData.h @@ -85,9 +85,9 @@ typedef void (*InitWorkData) (); // uint16_t (*GetCycleNumber) (struct VoltOutPara *) #define LIMIT \ - uint16_t _LimitValue; \ - void (*SetLimitValue) (struct Limit *, uint16_t); \ - uint16_t (*GetLimitValue) (struct Limit*) + uint32_t _LimitValue; \ + void (*SetLimitValue) (struct Limit *, uint32_t); \ + uint32_t (*GetLimitValue) (struct Limit*) struct Measure{ MEASURE; @@ -115,10 +115,10 @@ int32_t _GetMeasureData(struct Measure *self){ /**** Limit Mode ****/ //LimitValue -void _SetLimitValue(struct Limit *self, uint16_t LimitValue){ +void _SetLimitValue(struct Limit *self, uint32_t LimitValue){ self->_LimitValue = LimitValue; } -uint16_t _GetLimitValue(struct Limit *self){ +uint32_t _GetLimitValue(struct Limit *self){ return self->_LimitValue; } @@ -274,7 +274,7 @@ IVMode *InitIVMode(){ // ret->SetCycleNumber = &_SetCycleNumber; // ret->GetCycleNumber = &_GetCycleNumber; - ret->_LimitValue = 0; + ret->_LimitValue = 1e5; ret->SetLimitValue = &_SetLimitValue; ret->GetLimitValue = &_GetLimitValue; From 92b81cb47f286d5822e9b943693b645203bb48e2 Mon Sep 17 00:00:00 2001 From: 105042004 Date: Fri, 1 Nov 2019 18:47:01 +0800 Subject: [PATCH 4/5] check limit --- .../cc26xx/app/headstage/EliteITCurve.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h index 588ea5d88..d88e938ee 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h @@ -54,12 +54,12 @@ static int32_t IT_Plot(WorkMode *WorkModeData) { CURRENT_MODE->_MeasureData = Real_Current; - if(INSTRUCTION.eliteFxn == IV_CURVE){ - if(Real_Current > CURRENT_MODE->_LimitValue){ - PeriodicEvent = false; //Real current exceed expected limit value, force stop - DACReset = true; - } - } + // if(INSTRUCTION.eliteFxn == IV_CURVE){ + // if(Real_Current > CURRENT_MODE->_LimitValue){ + // PeriodicEvent = false; //Real current exceed expected limit value, force stop + // DACReset = true; + // } + // } NotifyCurrent[0] = (uint8_t) (Real_Current >> 24); NotifyCurrent[1] = (uint8_t) ((Real_Current & 0x00FF0000) >> 16); NotifyCurrent[2] = (uint8_t) ((Real_Current & 0x0000FF00) >> 8); From bc28dedc64da99aae18bf899e2befc99ca420b34 Mon Sep 17 00:00:00 2001 From: YiChin Date: Fri, 1 Nov 2019 19:30:30 +0800 Subject: [PATCH 5/5] IVmode stop and call reset() --- .../cc26xx/app/headstage/EliteITCurve.h | 18 ++++++++++-------- .../cc26xx/app/headstage/EliteIVCurve.h | 5 +++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h index d88e938ee..7e2cf40c3 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h @@ -2,6 +2,8 @@ #ifndef ELITEIT #define ELITEIT +#define absolute(a) ((a<0)? -a:a) + //static int32_t IT_Plot() { // // read ADC current // int32_t Real_Current = 0; @@ -20,11 +22,10 @@ // return Real_Current; //} -static int32_t IT_Plot(WorkMode *WorkModeData) { +static int32_t IT_Plot(WorkMode *WorkModeData) { switch (INSTRUCTION.eliteFxn) { case IV_CURVE:{ - #define CURRENT_MODE WorkModeData->IV break; } @@ -54,12 +55,13 @@ static int32_t IT_Plot(WorkMode *WorkModeData) { CURRENT_MODE->_MeasureData = Real_Current; - // if(INSTRUCTION.eliteFxn == IV_CURVE){ - // if(Real_Current > CURRENT_MODE->_LimitValue){ - // PeriodicEvent = false; //Real current exceed expected limit value, force stop - // DACReset = true; - // } - // } + if(INSTRUCTION.eliteFxn == IV_CURVE){ + if(absolute(Real_Current) > CURRENT_MODE->_LimitValue){ +// PeriodicEvent = false; //Real current exceed expected limit value, force stop +// DACReset = true; + reset(); + } + } NotifyCurrent[0] = (uint8_t) (Real_Current >> 24); NotifyCurrent[1] = (uint8_t) ((Real_Current & 0x00FF0000) >> 16); NotifyCurrent[2] = (uint8_t) ((Real_Current & 0x0000FF00) >> 8); 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 febc79da0..03c310170 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 @@ -74,8 +74,9 @@ static uint16_t OneWayVoltScan(IVMode *IV) { // end IV task if we reach INSTRUCTION.VoltFinal if (DACUserCode <= IV->_VStop){ - PeriodicEvent = false; - DACReset = true; +// PeriodicEvent = false; +// DACReset = true; + reset(); } } }