From d0f1cb5db090d54882790d166fbbf74f249c90f5 Mon Sep 17 00:00:00 2001 From: alan Date: Tue, 20 Aug 2019 14:31:02 +0800 Subject: [PATCH] Elite 1.4-re try to fix IV plot --- .../cc26xx/app/headstage/EliteDAC.h | 7 +++--- .../cc26xx/app/headstage/impedance_meter.h | 25 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDAC.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDAC.h index b9637f084..5d6aff271 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDAC.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteDAC.h @@ -78,12 +78,13 @@ static int32_t DAC_to_realV(uint16_t DACcode) //volt = (DAC -6.4893275)/(-0.0001896) int32_t RealV = 0; - int32_t volt_32 = DACcode*10e7; + int32_t volt_32 = 0; int32_t coeff = (-1896), offset = 64893275;//*10e7 - RealV = ((int32_t)(volt_32) - offset)/coeff; + volt_32 = DACcode * 10e7; + RealV = (volt_32 ) - offset) / coeff; - RealV = RealV/10e7; + RealV = RealV / 10e7; return RealV; } 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 5e4bb5fcf..bf4954839 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 @@ -150,23 +150,18 @@ static uint16_t VoltScan(){ return Voltage; } -static void Notify_IV(uint16_t Voltage, uint16_t Current) +static void Notify_IV(uint16_t Voltage) { int32_t RealV; int32_t RealC; RealV = DAC_to_realV(Voltage); - RealC = DecodeADCCurrent( (uint8_t)(2), Current); + NotifyVolt[0] = (uint8_t) (RealV >> 24); NotifyVolt[1] = (uint8_t) ((RealV & 0x00FF0000) >> 16); NotifyVolt[2] = (uint8_t) ((RealV & 0x0000FF00) >> 8); NotifyVolt[3] = (uint8_t) (RealV & 0x000000FF); - NotifyCurrent[0] = (uint8_t) (RealC >> 24); - NotifyCurrent[1] = (uint8_t) ((RealC & 0x00FF0000) >> 16); - NotifyCurrent[2] = (uint8_t) ((RealC & 0x0000FF00) >> 8); - NotifyCurrent[3] = (uint8_t) (RealC & 0x000000FF); - } static void fxn_Gen() {} @@ -905,6 +900,16 @@ static void SimpleBLEPeripheral_performPeriodicTask() { // Control ADC to sample rate EliteADCControl(); + uint16_t Current = 0x3FFF; + uint8_t GainLevel = 1; + + RealC = DecodeADCCurrent( GainLevel, Current); + NotifyCurrent[0] = (uint8_t) (RealC >> 24); + NotifyCurrent[1] = (uint8_t) ((RealC & 0x00FF0000) >> 16); + NotifyCurrent[2] = (uint8_t) ((RealC & 0x0000FF00) >> 8); + NotifyCurrent[3] = (uint8_t) (RealC & 0x000000FF); + + // Notify control, check if we need to send notify EliteNotifyControl(); } @@ -913,17 +918,14 @@ static void SimpleBLEPeripheral_performPeriodicTask() { static void EliteDACControl(){ uint16_t OutputV; - uint16_t Current; - Current = 0x3fff; if (INSTRUCTION.eliteFxn == ITCurve) { return; } if (INSTRUCTION.eliteFxn == VTCurve) { return; } if (StepTimeCounter == StepTime) { OutputV = VoltScan(); // output a certain voltage - Notify_IV(OutputV, Current); + Notify_IV(OutputV); } - } static void EliteADCControl(){ @@ -971,7 +973,6 @@ static void SendNotify(){ not_buf[17] = INSTRUCTION.CycleNumber; SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf); - } #endif /* IMPEDANCE_METER_H_ */