From a6c980cb0b20053856dbefeaa26a37f8f77afd4f Mon Sep 17 00:00:00 2001 From: Taylor Liao Date: Tue, 10 Aug 2021 16:37:56 +0800 Subject: [PATCH] Fixed Reverse Frequency Spacing (Linear) --- .../cc26xx/app/headstage/EliteDAC.h | 2 +- .../cc26xx/app/headstage/EliteEISMode.h | 6 +++--- .../cc26xx/app/headstage/EliteWorkData.h | 2 +- .../cc26xx/app/headstage/Elite_mode_ADC_DAC.h | 12 ++++++------ .../cc26xx/app/headstage/headstage.h | 6 +++--- 5 files changed, 14 insertions(+), 14 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 748f59cef..95f27da97 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 @@ -148,7 +148,7 @@ static uint32_t Freq2DAC(uint32_t freq){ if (freq == 100){ code = 1; } else { - code = freq / 0.0149 / 100 + 0.5; + code = (freq * 100 + 75) / 149; } return code; //return code } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteEISMode.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteEISMode.h index 5de3a984e..814ef9d08 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteEISMode.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteEISMode.h @@ -53,7 +53,7 @@ static void eis_fscan(void) instru.fset = (uint64_t)eis->_fd1 * LogSpacingTable[eis->_sweepIndex] / 1000; } else if (instru.scale == 1) { // linear - instru.fset = eis->_fd1 + eis->_sweepIndex * ((eis->_fd2 - eis->_fd1) / (eis->_ppd - 1) + 0.5); + instru.fset = eis->_fd1 + eis->_sweepIndex * ((eis->_fd2 - eis->_fd1) / (eis->_ppd - 1)); } } else { //reverse if(eis->_sweepIndex == 1){ @@ -67,10 +67,10 @@ static void eis_fscan(void) } if(instru.scale == 0) { // logarithm - instru.fset = (uint64_t)eis->_fd1 * LogSpacingTable[9 - eis->_sweepIndex] / 1000; + instru.fset = (uint64_t)eis->_fd2 * LogSpacingTable[9 - eis->_sweepIndex] / 1000; } else if(instru.scale == 1) { // linear - instru.fset = eis->_fd1 + eis->_sweepIndex * ((eis->_fd2 - eis->_fd1) / (eis->_ppd - 1) + 0.5); + instru.fset = eis->_fd1 - eis->_sweepIndex * ((eis->_fd1 - eis->_fd2) / (eis->_ppd - 1)); } } 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 06475e5df..d9a327203 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 @@ -62,7 +62,7 @@ struct wm_eis_ctx_t { uint8_t _decades; //num of decades in whole uint16_t _ppd; int8_t _decadeIndex; //index of decade max is 8 - uint16_t _sweepIndex; //index of smaller decade max is 10 + int16_t _sweepIndex; //index of smaller decade max is 10 bool _direction_up; }; diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_mode_ADC_DAC.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_mode_ADC_DAC.h index 376a4da7e..9e70b6698 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_mode_ADC_DAC.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/Elite_mode_ADC_DAC.h @@ -135,14 +135,14 @@ static int16_t CalcPhase() instru.real = neg_18bit(ReadRealZ()); instru.imag = neg_18bit(ReadImagZ()); - ret = (atan((1000 * instru.imag / instru.real) / 1000) * 1000); - phase1 = (int16_t)(ret * 180000 + 1570)/ 3140; + ret = atan(1000 * instru.imag / instru.real / 1000) * 1000; + phase1 = (ret * 180000 + 1570)/ 3140; phase2 = (phase1 - 15 * instru.fset + 90000 + 500000) / 1000000; - InputNotify(NOTIFY_IMPEDANCE, ret); - InputNotify(NOTIFY_VOLT, instru.real); - InputNotify(NOTIFY_CURRENT, instru.imag); +// InputNotify(NOTIFY_IMPEDANCE, ret); +// InputNotify(NOTIFY_VOLT, instru.real); +// InputNotify(NOTIFY_CURRENT, instru.imag); return phase2; } @@ -500,7 +500,7 @@ static void CC_Plot(void) //real and imag impedance plot } else if (ADC_cnt == 1) { // HSTIA_change_gain(); // MEAS_CURR(wm) = read_HSTIA_Iin(); - CalcPhase(); +// CalcPhase(); ADC_cnt++; } else if (ADC_cnt == 2) { 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 2d22d91a9..9f596a78d 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 @@ -685,8 +685,8 @@ static void update_ZM_instruction(uint8 *ins) { case CURVE_EIS: { //0xD1 if (ins[3] == PARA_1) { //3000D1 01 instru.sampleRate = 15; //ms //vscan - instru.f1 = 6711409;//((uint32_t)(ins[4]) << 24) | ((uint32_t)(ins[5]) << 16) | ((uint32_t)(ins[6]) << 8) | (uint32_t)(ins[7]); //FREQ_START - instru.f2 = 67;//((uint32_t)(ins[8]) << 24) | ((uint32_t)(ins[9]) << 16) | ((uint32_t)(ins[10]) << 8) | (uint32_t)(ins[11]); //FREQ_STOP + instru.f1 = 67;//((uint32_t)(ins[4]) << 24) | ((uint32_t)(ins[5]) << 16) | ((uint32_t)(ins[6]) << 8) | (uint32_t)(ins[7]); //FREQ_START + instru.f2 = 6711409;//((uint32_t)(ins[8]) << 24) | ((uint32_t)(ins[9]) << 16) | ((uint32_t)(ins[10]) << 8) | (uint32_t)(ins[11]); //FREQ_STOP instru.fmax = (uint32_t)VMAX(instru.f1, instru.f2); instru.fmin = (uint32_t)VMIN(instru.f1, instru.f2); instru.delay = 1;//((uint16_t)(ins[12]) << 8) | (uint16_t)(ins[13]); //DELAY how many periods @@ -704,7 +704,7 @@ static void update_ZM_instruction(uint8 *ins) { instru.avgnum = 2;//(uint8_t)(ins[8]); instru.rtia = 4;//(uint8_t)(ins[9]); instru.ppd = 10;//((uint16_t)(ins[10]) << 8) | (uint16_t)(ins[11]); - instru.scale = 0;//(uint8_t)(ins[12]); + instru.scale = 1;//(uint8_t)(ins[12]); setEIS_EIS(); DAC_outputV(instru.dcbias);