diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCVCurve.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCVCurve.h index f65ad5123..21814a210 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCVCurve.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCVCurve.h @@ -139,7 +139,7 @@ static uint16_t CVCurve(CVMode *CV) { static bool firstADCData; //firstADCdata=true,when min_VOrigin; + INSTRUCTION.VoltConstant = CV->_VOrigin; if (CV->_VStop > CV->_VOrigin) { direction_up = true; current_direction_up = true; @@ -148,7 +148,7 @@ static uint16_t CVCurve(CVMode *CV) { current_direction_up = false; } - DACOutCode = Usercode_Correction_to_DAC(DACUserCode); + DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant); DAC_outputV(DACOutCode); // output VOLT_ORIGIN DACReset = false; firstADCData = true; @@ -159,36 +159,11 @@ static uint16_t CVCurve(CVMode *CV) { // Decide next direction if (CV->_VoVi_Switch == 0x00){ //user see Vout if (direction_up) { - if (DACUserCode >= CV->_VStop) { - current_direction_up = false; // problem occurs when origin == 0000 final == ffff!!!!!! - } else if (DACUserCode <= CV->_VOrigin) { - current_direction_up = true; - if (CV->_CycleNumber == 0) { - PeriodicEvent = false; // periodic event end - DACReset = true; - } - CV->_CycleNumber--; - } - } else { - if (DACUserCode <= CV->_VStop) { - current_direction_up = true; // problem occurs when origin == 0000 final == ffff!!!!!! - } else if (DACUserCode >= CV->_VOrigin) { - current_direction_up = false; - if (CV->_CycleNumber == 0) { - PeriodicEvent = false; // periodic event end - DACReset = true; - } - CV->_CycleNumber--; - } - } - } - else if (CV->_VoVi_Switch == 0x01){ //user see Vin - if (direction_up) { - if (CV->MeasureVolt/1000 >= ((int32_t)(CV->_VStop) - DAC_ZERO)/5) { + if (INSTRUCTION.VoltConstant >= CV->_VStop) { current_direction_up = false; // problem occurs when origin == 0000 final == ffff!!!!!! firstADCData = false; } - else if (CV->MeasureVolt/1000 <= ((int32_t)(CV->_VOrigin) - DAC_ZERO)/5) { + else if (INSTRUCTION.VoltConstant <= CV->_VOrigin) { current_direction_up = true; firstADCData = false; if (CV->_CycleNumber == 0) { @@ -200,12 +175,12 @@ static uint16_t CVCurve(CVMode *CV) { else if(current_direction_up){ - if(CV->MeasureVolt/1000 + ((int32_t)(CV->_Step) - DAC_ZERO)/5 > ((int32_t)(CV->_VStop) - DAC_ZERO)/5){ + if(INSTRUCTION.VoltConstant + CV->_Step > CV->_VStop){ current_direction_up = false; } } else if(!current_direction_up){ - if(CV->MeasureVolt/1000 - ((int32_t)(CV->_Step) - DAC_ZERO)/5 < ((int32_t)(CV->_VOrigin) - DAC_ZERO)/5){ + if(INSTRUCTION.VoltConstant - CV->_Step < CV->_VOrigin){ current_direction_up = true; if (CV->_CycleNumber == 0) { PeriodicEvent = false; // periodic event end @@ -220,11 +195,11 @@ static uint16_t CVCurve(CVMode *CV) { } } else { - if (CV->MeasureVolt/1000 <= ((int32_t)(CV->_VStop) - DAC_ZERO)/5) { + if (INSTRUCTION.VoltConstant < CV->_VStop) { current_direction_up = true; // problem occurs when origin == 0000 final == ffff!!!!!! firstADCData = false; } - else if (CV->MeasureVolt/1000 >= ((int32_t)(CV->_VOrigin) - DAC_ZERO)/5){ + else if (INSTRUCTION.VoltConstant > CV->_VOrigin) { current_direction_up = false; firstADCData = false; if (CV->_CycleNumber == 0) { @@ -234,7 +209,7 @@ static uint16_t CVCurve(CVMode *CV) { CV->_CycleNumber--; } else if(current_direction_up){ - if(CV->MeasureVolt/1000 + ((int32_t)(CV->_Step) - DAC_ZERO)/5 > ((int32_t)(CV->_VOrigin) - DAC_ZERO)/5){ + if(INSTRUCTION.VoltConstant + CV->_Step > CV->_VOrigin){ current_direction_up = false; if (CV->_CycleNumber == 0) { PeriodicEvent = false; // periodic event end @@ -244,7 +219,79 @@ static uint16_t CVCurve(CVMode *CV) { } } else if(!current_direction_up){ - if(CV->MeasureVolt/1000 - ((int32_t)(CV->_Step) - DAC_ZERO)/5 < ((int32_t)(CV->_VStop) - DAC_ZERO)/5){ + if(INSTRUCTION.VoltConstant - CV->_Step < CV->_VStop){ + current_direction_up = true; + } + } + if (firstADCData){//first data =2899mv,CV->_CycleNumber--; + CV->_CycleNumber--; + firstADCData = false; + } + } + } + else if (CV->_VoVi_Switch == 0x01){ //user see Vin + if (direction_up) { + if (INSTRUCTION.VoltConstant >= CV->_VStop) { + current_direction_up = false; // problem occurs when origin == 0000 final == ffff!!!!!! + firstADCData = false; + } + else if (INSTRUCTION.VoltConstant <= CV->_VOrigin) { + current_direction_up = true; + firstADCData = false; + if (CV->_CycleNumber == 0) { + PeriodicEvent = false; // periodic event end + DACReset = true; + } + CV->_CycleNumber--; + } + + + else if(current_direction_up){ + if(INSTRUCTION.VoltConstant + CV->_Step > CV->_VStop){ + current_direction_up = false; + } + } + else if(!current_direction_up){ + if(INSTRUCTION.VoltConstant - CV->_Step < CV->_VOrigin){ + current_direction_up = true; + if (CV->_CycleNumber == 0) { + PeriodicEvent = false; // periodic event end + DACReset = true; + } + CV->_CycleNumber--; + } + } + if (firstADCData){ + CV->_CycleNumber--; + firstADCData = false; + } + + } else { + if (INSTRUCTION.VoltConstant < CV->_VStop) { + current_direction_up = true; // problem occurs when origin == 0000 final == ffff!!!!!! + firstADCData = false; + } + else if (INSTRUCTION.VoltConstant > CV->_VOrigin){ + current_direction_up = false; + firstADCData = false; + if (CV->_CycleNumber == 0) { + PeriodicEvent = false; // periodic event end + DACReset = true; + } + CV->_CycleNumber--; + } + else if(current_direction_up){ + if(INSTRUCTION.VoltConstant + CV->_Step > CV->_VOrigin){ + current_direction_up = false; + if (CV->_CycleNumber == 0) { + PeriodicEvent = false; // periodic event end + DACReset = true; + } + CV->_CycleNumber--; + } + } + else if(!current_direction_up){ + if(INSTRUCTION.VoltConstant - CV->_Step < CV->_VStop){ current_direction_up = true; } } @@ -266,53 +313,80 @@ static uint16_t CVCurve(CVMode *CV) { if (direction_up) { if (current_direction_up) { // DACUserCode overflow ? - if (DACUserCode + CV->_Step < DACUserCode) { - DACUserCode = CV->_VStop; + if (INSTRUCTION.VoltConstant + CV->_Step < INSTRUCTION.VoltConstant) { + INSTRUCTION.VoltConstant = CV->_VStop; } // reach Vfinal ? - else if (DACUserCode + CV->_Step > CV->_VStop) { - DACUserCode =CV->_VStop; + else if (INSTRUCTION.VoltConstant + CV->_Step > CV->_VStop) { + INSTRUCTION.VoltConstant =CV->_VStop; + } + else if (INSTRUCTION.VoltConstant >= CV->_VStop){ + INSTRUCTION.VoltConstant =CV->_VStop; } else { - DACUserCode = DACUserCode + CV->_Step; + INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + CV->_Step; } } else { // DACUserCode underflow ? - if (DACUserCode - CV->_Step > DACUserCode) { - DACUserCode = CV->_VOrigin; + if (INSTRUCTION.VoltConstant - CV->_Step > INSTRUCTION.VoltConstant) { + INSTRUCTION.VoltConstant = CV->_VOrigin; } - // reach Vorigin ? - else if (DACUserCode - CV->_Step < CV->_VOrigin) { - DACUserCode = CV->_VOrigin; + else if (INSTRUCTION.VoltConstant - CV->_Step < CV->_VOrigin) { + INSTRUCTION.VoltConstant = CV->_VOrigin; + } + else if (INSTRUCTION.VoltConstant <= CV->_VOrigin){ + INSTRUCTION.VoltConstant = CV->_VOrigin; } else { - DACUserCode = DACUserCode - CV->_Step; + INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - CV->_Step; + if(INSTRUCTION.VoltConstant > 60000){ + INSTRUCTION.VoltConstant = 0; + current_direction_up = true; + if (CV->_CycleNumber == 0) { + PeriodicEvent = false; // periodic event end + DACReset = true; + } + CV->_CycleNumber--; + } } } } else { if (current_direction_up) { - if (DACUserCode + CV->_Step < DACUserCode) { - DACUserCode = CV->_VOrigin; + + if (INSTRUCTION.VoltConstant + CV->_Step < INSTRUCTION.VoltConstant) { + INSTRUCTION.VoltConstant = CV->_VOrigin; } - else if (DACUserCode + CV->_Step > CV->_VOrigin) { - DACUserCode = CV->_VOrigin; + + else if (INSTRUCTION.VoltConstant + CV->_Step > CV->_VOrigin) { + INSTRUCTION.VoltConstant = CV->_VOrigin; + } + else if (INSTRUCTION.VoltConstant >= CV->_VOrigin){ + INSTRUCTION.VoltConstant = CV->_VOrigin; } else { - DACUserCode = DACUserCode + CV->_Step; + INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + CV->_Step; } } else { - if (DACUserCode - CV->_Step > DACUserCode) { - DACUserCode = CV->_VStop ; + if (INSTRUCTION.VoltConstant - CV->_Step > INSTRUCTION.VoltConstant) { + INSTRUCTION.VoltConstant = CV->_VStop ; } - else if (DACUserCode - CV->_Step < CV->_VStop) { - DACUserCode = CV->_VStop; + else if (INSTRUCTION.VoltConstant - CV->_Step < CV->_VStop) { + INSTRUCTION.VoltConstant = CV->_VStop; + } + else if(INSTRUCTION.VoltConstant <= CV->_VStop){ + INSTRUCTION.VoltConstant = CV->_VStop; } else { - DACUserCode = DACUserCode - CV->_Step; + INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - CV->_Step; + + if(INSTRUCTION.VoltConstant > 60000){ + INSTRUCTION.VoltConstant = 0; + current_direction_up = true; + } } } } @@ -321,36 +395,36 @@ static uint16_t CVCurve(CVMode *CV) { if (direction_up) { if (current_direction_up) { // DACUserCode overflow ? - if (DACUserCode + CV->_Step < DACUserCode) { - DACUserCode = CV->_VStop; + if (INSTRUCTION.VoltConstant + CV->_Step < INSTRUCTION.VoltConstant) { + INSTRUCTION.VoltConstant = CV->_VStop; } // reach Vfinal ? - else if (CV->MeasureVolt/1000 + ((int32_t)(CV->_Step) - DAC_ZERO)/5 > ((int32_t)(CV->_VStop) - DAC_ZERO)/5) { - DACUserCode =CV->_VStop; + else if (INSTRUCTION.VoltConstant + CV->_Step > CV->_VStop) { + INSTRUCTION.VoltConstant =CV->_VStop; } - else if (CV->MeasureVolt/1000 >= ((int32_t)(CV->_VStop) - DAC_ZERO)/5){ - DACUserCode =CV->_VStop; + else if (INSTRUCTION.VoltConstant >= CV->_VStop){ + INSTRUCTION.VoltConstant =CV->_VStop; } else { - DACUserCode = DACUserCode + CV->_Step; + INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + CV->_Step; } } else { // DACUserCode underflow ? - if (DACUserCode - CV->_Step > DACUserCode) { - DACUserCode = CV->_VOrigin; + if (INSTRUCTION.VoltConstant - CV->_Step > INSTRUCTION.VoltConstant) { + INSTRUCTION.VoltConstant = CV->_VOrigin; } // reach Vorigin ? - else if (CV->MeasureVolt/1000 - ((int32_t)(CV->_Step) - DAC_ZERO)/5 < ((int32_t)(CV->_VOrigin) - DAC_ZERO)/5) { - DACUserCode = CV->_VOrigin; + else if (INSTRUCTION.VoltConstant - CV->_Step < CV->_VOrigin) { + INSTRUCTION.VoltConstant = CV->_VOrigin; } - else if (CV->MeasureVolt/1000 <= ((int32_t)(CV->_VOrigin) - DAC_ZERO)/5){ - DACUserCode = CV->_VOrigin; + else if (INSTRUCTION.VoltConstant <= CV->_VOrigin){ + INSTRUCTION.VoltConstant = CV->_VOrigin; } else { - DACUserCode = DACUserCode - CV->_Step; - if(DACUserCode > 60000){ - DACUserCode = 0; + INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - CV->_Step; + if(INSTRUCTION.VoltConstant > 60000){ + INSTRUCTION.VoltConstant = 0; current_direction_up = true; if (CV->_CycleNumber == 0) { PeriodicEvent = false; // periodic event end @@ -364,35 +438,35 @@ static uint16_t CVCurve(CVMode *CV) { else { if (current_direction_up) { // DACUserCode overflow ? - if (DACUserCode + CV->_Step < DACUserCode) { - DACUserCode = CV->_VOrigin; + if (INSTRUCTION.VoltConstant + CV->_Step < INSTRUCTION.VoltConstant) { + INSTRUCTION.VoltConstant = CV->_VOrigin; } // ex:command 3->1V ,when 1 to 3V, 2.99+0.1 > 3V - else if (CV->MeasureVolt/1000 + ((int32_t)(CV->_Step) - DAC_ZERO)/5 > ((int32_t)(CV->_VOrigin) - DAC_ZERO)/5) { - DACUserCode = CV->_VOrigin; + else if (INSTRUCTION.VoltConstant + CV->_Step > CV->_VOrigin) { + INSTRUCTION.VoltConstant = CV->_VOrigin; } - else if (CV->MeasureVolt/1000 >= ((int32_t)(CV->_VOrigin) - DAC_ZERO)/5){ - DACUserCode = CV->_VOrigin; + else if (INSTRUCTION.VoltConstant >= CV->_VOrigin){ + INSTRUCTION.VoltConstant = CV->_VOrigin; } else { - DACUserCode = DACUserCode + CV->_Step; + INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + CV->_Step; } } else { - if (DACUserCode - CV->_Step > DACUserCode) { - DACUserCode = CV->_VStop ; + if (INSTRUCTION.VoltConstant - CV->_Step > INSTRUCTION.VoltConstant) { + INSTRUCTION.VoltConstant = CV->_VStop ; } - else if (CV->MeasureVolt/1000 - ((int32_t)(CV->_Step) - DAC_ZERO)/5 < ((int32_t)(CV->_VStop) - DAC_ZERO)/5) { - DACUserCode = CV->_VStop; + else if (INSTRUCTION.VoltConstant - CV->_Step < CV->_VStop) { + INSTRUCTION.VoltConstant = CV->_VStop; } - else if(CV->MeasureVolt/1000 <= ((int32_t)(CV->_VStop) - DAC_ZERO)/5){ - DACUserCode = CV->_VStop; + else if(INSTRUCTION.VoltConstant <= CV->_VStop){ + INSTRUCTION.VoltConstant = CV->_VStop; } else { - DACUserCode = DACUserCode - CV->_Step; + INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - CV->_Step; - if(DACUserCode > 60000){ - DACUserCode = 0; + if(INSTRUCTION.VoltConstant > 60000){ + INSTRUCTION.VoltConstant = 0; current_direction_up = true; } } @@ -400,13 +474,13 @@ static uint16_t CVCurve(CVMode *CV) { } } - NotifyImpedance[0] = 0x00; - NotifyImpedance[1] = 0x00; - NotifyImpedance[2] = (uint8_t)((DACOutCode & 0xFF00) >> 8); - NotifyImpedance[3] = (uint8_t)(DACOutCode & 0x00FF); +// NotifyImpedance[0] = 0x00; +// NotifyImpedance[1] = 0x00; +// NotifyImpedance[2] = (uint8_t)((DACOutCode & 0xFF00) >> 8); +// NotifyImpedance[3] = (uint8_t)(DACOutCode & 0x00FF); - DACOutCode = Usercode_Correction_to_DAC(DACUserCode); + DACOutCode = Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant); DAC_outputV(DACOutCode); } return DACOutCode; @@ -504,10 +578,17 @@ static void CV_Plot(CVMode *CV){ NotifyCurrent[3] = (uint8_t) (CV->_MeasureData & 0x000000FF); if ((CV->_VoVi_Switch == 0x01) || (CV->_VoVi_Switch == 0x00)){ //user see Vin || user see Vout - NotifyVolt[0] = (uint8_t) (CV->MeasureVolt >> 24); - NotifyVolt[1] = (uint8_t) ((CV->MeasureVolt & 0x00FF0000) >> 16); - NotifyVolt[2] = (uint8_t) ((CV->MeasureVolt & 0x0000FF00) >> 8); - NotifyVolt[3] = (uint8_t) (CV->MeasureVolt & 0x000000FF); +// NotifyVolt[0] = (uint8_t) (CV->MeasureVolt >> 24); +// NotifyVolt[1] = (uint8_t) ((CV->MeasureVolt & 0x00FF0000) >> 16); +// NotifyVolt[2] = (uint8_t) ((CV->MeasureVolt & 0x0000FF00) >> 8); +// NotifyVolt[3] = (uint8_t) (CV->MeasureVolt & 0x000000FF); + + int32_t RealV; + RealV = (int32_t)(INSTRUCTION.VoltConstant - 25000)*1000/5; + NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24); + NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16); + NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8); + NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF); } // NotifyBatVolt = (uint8_t) (CV->_MeasureBatvolt & 0x000000FF); diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h index 161df0bd7..7f31d6975 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDeviceCorrection.h @@ -313,23 +313,23 @@ struct _correction{ #ifdef BOARD_517 { -.ADC_volt.coeff = (-6244769), -.ADC_volt.offset = 101714685687, +.ADC_volt.coeff = (-6242316), +.ADC_volt.offset = 101695491616, -.ADC_current[0].coeff = 30919726, -.ADC_current[0].offset = (-503489101786), +.ADC_current[0].coeff = 31169316, +.ADC_current[0].offset = (-507589234000), -.ADC_current[1].coeff = 654824495, -.ADC_current[1].offset = (-10660542778914), +.ADC_current[1].coeff = 657889599, +.ADC_current[1].offset = (-10712745285212), -.ADC_current[2].coeff = 31376265, -.ADC_current[2].offset = (-510797752348), +.ADC_current[2].coeff = 31568312650, +.ADC_current[2].offset = (-514058403190859), .DAC2RealV.coeff = (-18690126), .DAC2RealV.offset = 564319610294 , -.Usercode2DAC.coeff = (-10500774), -.Usercode2DAC.offset = 560779455904, +.Usercode2DAC.coeff = (-10498485), +.Usercode2DAC.offset = 560797798529, .Gain0Boundary[0] = 0x5E2F, .Gain0Boundary[1] = 0x5E96, @@ -537,23 +537,23 @@ struct _correction{ #ifdef BOARD_VENUS { -.ADC_volt.coeff = (-6268996), -.ADC_volt.offset = 102204055818, +.ADC_volt.coeff = (-6269185), +.ADC_volt.offset = 102228792306, -.ADC_current[0].coeff = 31131930, -.ADC_current[0].offset = (-507382432547), +.ADC_current[0].coeff = 31229744, +.ADC_current[0].offset = (-509240005160), -.ADC_current[1].coeff = 654620883, -.ADC_current[1].offset = (-10668953588943), +.ADC_current[1].coeff = 671245720, +.ADC_current[1].offset = (-10939750446252), -.ADC_current[2].coeff = 31245260000, -.ADC_current[2].offset = (-509181085054000), +.ADC_current[2].coeff = 35220821945, +.ADC_current[2].offset = (-574099564362474), .DAC2RealV.coeff = (-19009388), .DAC2RealV.offset = 567032653061, -.Usercode2DAC.coeff = (-10521117), -.Usercode2DAC.offset = 561308254899, +.Usercode2DAC.coeff = (-10524891), +.Usercode2DAC.offset = 561393946495, .Gain0Boundary[0] = 0x5D96, .Gain0Boundary[1] = 0x5DD9, @@ -621,8 +621,8 @@ struct _correction{ #ifdef BOARD_SATURN { -.ADC_volt.coeff = (-6262993), -.ADC_volt.offset = 101996256499, +.ADC_volt.coeff = (-6262258), +.ADC_volt.offset = 101986379869, .ADC_current[0].coeff = 31482854, .ADC_current[0].offset = (-513080696050), @@ -630,14 +630,14 @@ struct _correction{ .ADC_current[1].coeff = 660069824, .ADC_current[1].offset = (-10757047907091), -.ADC_current[2].coeff = 31599480301, -.ADC_current[2].offset = (-514997796786064), +.ADC_current[2].coeff = 31692010534, +.ADC_current[2].offset = (-516553361701835), .DAC2RealV.coeff = (-19009388), .DAC2RealV.offset = 567032653061, -.Usercode2DAC.coeff = (-10482326), -.Usercode2DAC.offset = 558931155711, +.Usercode2DAC.coeff = (-10484502), +.Usercode2DAC.offset = 558944670693, .Gain0Boundary[0] = 0x5D96, .Gain0Boundary[1] = 0x5DD9, @@ -1039,6 +1039,34 @@ struct _correction{ }; #endif +#ifdef BOARD_C5E0 +{ +.ADC_volt.coeff = (-6245327), +.ADC_volt.offset = 101307483012, + +.ADC_current[0].coeff = 31354974, +.ADC_current[0].offset = -507194879524, + +.ADC_current[1].coeff = 658451900, +.ADC_current[1].offset = -10677456008545, + +.ADC_current[2].coeff = 31568312650, +.ADC_current[2].offset = -511943326243316, + +.DAC2RealV.coeff = (-19007867), +.DAC2RealV.offset = 646316924837, + +.Usercode2DAC.coeff = (-21557794), +.Usercode2DAC.offset = 1122382223883, + +.Gain0Boundary[0] = 0x5ECD, +.Gain0Boundary[1] = 0x5F0D, + +.Gain1Boundary[0] = 0x5900, +.Gain1Boundary[1] = 0x64DD +}; +#endif + #ifdef BOARD_C64C { .ADC_volt.coeff = (-6260844), @@ -1378,6 +1406,33 @@ struct _correction{ }; #endif +#ifdef BOARD_C706 +{ +.ADC_volt.coeff = (-6265060), +.ADC_volt.offset = 101304934795, + +.ADC_current[0].coeff = 31017413, +.ADC_current[0].offset = -501641612769, + +.ADC_current[1].coeff = 657630384, +.ADC_current[1].offset = -10633992921166, + +.ADC_current[2].coeff = 31013727410, +.ADC_current[2].offset = -501507479075525, + +.DAC2RealV.coeff = (-19007867), +.DAC2RealV.offset = 646316924837, + +.Usercode2DAC.coeff = (-10557808), +.Usercode2DAC.offset = 560287506126, + +.Gain0Boundary[0] = 0x5ECD, +.Gain0Boundary[1] = 0x5F0D, + +.Gain1Boundary[0] = 0x5900, +.Gain1Boundary[1] = 0x64DD +}; +#endif // this function turn ADC measure value (0xXXXX) into real voltage // unit should be uV 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 0988307cd..110549995 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 @@ -77,27 +77,34 @@ static uint16_t OneWayVoltScan(IVMode *IV) { // } } - if (IV->_VoVi_Switch == 0x00 || IV->_VoVi_Switch == 0x01){ //user see Vout/user see Vin - if (IV->_VOrigin < IV->_VStop) { - if(INSTRUCTION.VoltConstant >= IV->_VStop){ - PeriodicEvent = false; - DACReset = true; - } - } - else{ - if(INSTRUCTION.VoltConstant <= IV->_VStop){ - PeriodicEvent = false; - DACReset = true; - } - } - } +// if (IV->_VoVi_Switch == 0x00 || IV->_VoVi_Switch == 0x01){ //user see Vout/user see Vin +// if (IV->_VOrigin < IV->_VStop) { +// if(INSTRUCTION.VoltConstant >= IV->_VStop){ +// PeriodicEvent = false; +// DACReset = true; +// } +// } +// else{ +// if(INSTRUCTION.VoltConstant <= IV->_VStop){ +// PeriodicEvent = false; +// DACReset = true; +// } +// } +// } - int32_t RealV; - RealV = DAC_to_realV(DACOutCode); - NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24); - NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16); - NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8); - NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF); +// int32_t RealV; +// RealV = DAC_to_realV(DACOutCode); +// NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24); +// NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16); +// NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8); +// NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF); + +// int32_t RealV; +// RealV = (int32_t)(INSTRUCTION.VoltConstant - 25000)/5*1000; +// NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24); +// NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16); +// NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8); +// NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF); // NotifyImpedance[0] = 0x00; @@ -201,20 +208,48 @@ static void IV_Plot(IVMode *IV) { NotifyCurrent[2] = (uint8_t) ((IV->_MeasureData & 0x0000FF00) >> 8); NotifyCurrent[3] = (uint8_t) (IV->_MeasureData & 0x000000FF); - if((IV->_VoVi_Switch == 0x01) || (IV->_VoVi_Switch == 0x00)){ //user see Vin || user see Vout - NotifyVolt[0] = (uint8_t) (IV->MeasureVolt >> 24); - NotifyVolt[1] = (uint8_t) ((IV->MeasureVolt & 0x00FF0000) >> 16); - NotifyVolt[2] = (uint8_t) ((IV->MeasureVolt & 0x0000FF00) >> 8); - NotifyVolt[3] = (uint8_t) (IV->MeasureVolt & 0x000000FF); +// if((IV->_VoVi_Switch == 0x01) || (IV->_VoVi_Switch == 0x00)){ //user see Vin || user see Vout +//// NotifyVolt[0] = (uint8_t) (IV->MeasureVolt >> 24); +//// NotifyVolt[1] = (uint8_t) ((IV->MeasureVolt & 0x00FF0000) >> 16); +//// NotifyVolt[2] = (uint8_t) ((IV->MeasureVolt & 0x0000FF00) >> 8); +//// NotifyVolt[3] = (uint8_t) (IV->MeasureVolt & 0x000000FF); +// int32_t RealV; +// RealV = (int32_t)(INSTRUCTION.VoltConstant - 25000)/5*1000; +// NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24); +// NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16); +// NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8); +// NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF); +// +// if (IV->_VOrigin < IV->_VStop) { +// if((IV->MeasureVolt/1000) >= ((int32_t) (IV->_VStop) - DAC_ZERO)/5){ +// PeriodicEvent = false; +// DACReset = true; +// } +// } +// else{ +// if((IV->MeasureVolt/1000) <= ((int32_t) (IV->_VStop) - DAC_ZERO)/5){ +// PeriodicEvent = false; +// DACReset = true; +// } +// } +// } + + if (IV->_VoVi_Switch == 0x00 || IV->_VoVi_Switch == 0x01){ //user see Vout/user see Vin + int32_t RealV; + RealV = (int32_t)(INSTRUCTION.VoltConstant - 25000)*1000/5; + NotifyVolt[0] = (uint8_t)((RealV & 0xFF000000) >> 24); + NotifyVolt[1] = (uint8_t)((RealV & 0x00FF0000) >> 16); + NotifyVolt[2] = (uint8_t)((RealV & 0x0000FF00) >> 8); + NotifyVolt[3] = (uint8_t)(RealV & 0x000000FF); if (IV->_VOrigin < IV->_VStop) { - if((IV->MeasureVolt/1000) >= ((int32_t) (IV->_VStop) - DAC_ZERO)/5){ + if(INSTRUCTION.VoltConstant >= IV->_VStop){ PeriodicEvent = false; DACReset = true; } } else{ - if((IV->MeasureVolt/1000) <= ((int32_t) (IV->_VStop) - DAC_ZERO)/5){ + if(INSTRUCTION.VoltConstant <= IV->_VStop){ PeriodicEvent = false; DACReset = true; } 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 6d6b0dc4a..8c419600c 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 @@ -493,6 +493,7 @@ static uint8 channel_table[CHANNEL_COUNT] = {0}; */ static int8 channel_pointer = -1; static uint8_t not_buf[BLE_DAT_BUFF_SIZE] = {0}; +static uint8_t cis_buf[BLE_CIS_BUFF_SIZE] = {0}; /*===================================== ==== headstage function prototype ==== @@ -599,6 +600,7 @@ static void set_update_instruction_callback(update_instruction_callback_type cal #define CYCLE_CONSTANT_CURRENT 0b11110000 // CIS instruction +#define CIS_VERSION 0x40 // test instruction #define ADC_TEST 0b10010000 @@ -701,6 +703,7 @@ static void TurnOn10V(); #include "EliteCCCMode.h" #include "impedance_meter.h" #include "EliteReadVout.h" +#include "headstage_version.h" // update instruction for Z meter static void update_ZM_instruction(uint8 *ins) { @@ -827,7 +830,7 @@ static void update_ZM_instruction(uint8 *ins) { // CleanBuffer(); INSTRUCTION.eliteFxn = CV_CURVE; DACReset = true; - INSTRUCTION.SampleRate = 500; + INSTRUCTION.SampleRate = 100; // if (ins[3] | ins[4]) { INSTRUCTION.VoltOrigin = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]); @@ -1119,6 +1122,19 @@ static void update_ZM_instruction(uint8 *ins) { I2CWrite(0x01, 0xAB); break; } + + case CIS_VERSION:{ + cis_buf[0] = VERSION_DATE_YEAR; + cis_buf[1] = VERSION_DATE_MONTH; + cis_buf[2] = VERSION_DATE_DAY; + cis_buf[3] = VERSION_DATE_HOUR; + cis_buf[4] = VERSION_DATE_MINUTE; + + SimpleProfile_SetParameter(BLE_CIS_BUFF_CHAR, BLE_CIS_BUFF_SIZE, cis_buf); + break; + } + + } break; } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h new file mode 100644 index 000000000..04d9c1aaa --- /dev/null +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_version.h @@ -0,0 +1,11 @@ + +#ifndef VERSION_DATE +#define VERSION_DATE + +#define VERSION_DATE_YEAR 20 +#define VERSION_DATE_MONTH 2 +#define VERSION_DATE_DAY 21 +#define VERSION_DATE_HOUR 17 +#define VERSION_DATE_MINUTE 57 + +#endif diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c index 1e06572ce..f41fe04dc 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c @@ -632,6 +632,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { InitEliteInstruction(); ADCGainControl(INSTRUCTION.ADCGainLevel); DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant)); + Free_Work_Mode = false; } } else { @@ -648,8 +649,12 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) { // Perform periodic application task SimpleBLEPeripheral_performPeriodicTask(WorkModeData); + // Turn off Elite if battery voltage < 3V +// ReadBatVolt(spi_ADC_rxbuf); + key = PIN_getInputValue(switch_on); EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650 + } }