From 6031a35461dbe252f2bb1b4140fd60339319d2e2 Mon Sep 17 00:00:00 2001 From: 105042004 Date: Tue, 13 Aug 2019 12:24:51 +0800 Subject: [PATCH] update step amplitide width --- .../cc26xx/app/headstage/headstage.h | 63 ++++++++----------- .../cc26xx/app/headstage/impedance_meter.h | 40 ++++++------ 2 files changed, 46 insertions(+), 57 deletions(-) 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 6cd85a15d..7e6023a11 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 @@ -671,13 +671,12 @@ static void DAC_outputV(uint16_t voltLV); // input parameter static uint16_t VoltOrigin = DACzero; static uint16_t VoltFinal = DACposMax; -static uint8_t Step = 0xF0; // 10 => 0xA0 ~= 30.5 mv +static uint16_t Step = 0x00F0; // 10 => 0xA0 ~= 30.5 mv //for DPVCurve SWVCurve -static uint8_t Amplitude = 0x00; +static uint16_t Amplitude = 0x00; static uint8_t PulseWidth = 0x00; static uint8_t PulsePeriod = 0x00; -static uint8_t Increase = 0x00; static uint8_t StepTime = 0x18; // 0x30 = 2'd48 ~= 2 second, 24 = 0x18 = 1 sec static uint8_t PeriodicCounter = 0; @@ -741,11 +740,11 @@ static void update_ZM_instruction(uint8 *ins) { VoltFinal = ((uint16_t) (ins[5]) << 8) | (uint16_t) (ins[6]); } - if(ins[7]){ - Step = ins[7]; + if(ins[7] | ins[8]){ + Step = ((uint16_t) (ins[7]) << 8) | (uint16_t) (ins[8]); } - if(ins[8]){ - StepTime = ins[8]; + if(ins[9]){ + StepTime = ins[9]; } break; } @@ -761,23 +760,20 @@ static void update_ZM_instruction(uint8 *ins) { VoltFinal = ((uint16_t) (ins[5]) << 8) | (uint16_t) (ins[6]); } - if(ins[7]){ - Step = ins[7]; - } - if(ins[8]){ - StepTime = ins[8]; + if(ins[7] | ins[8]){ + Step = ((uint16_t) (ins[7]) << 8) | (uint16_t) (ins[8]); } if(ins[9]){ - INSTRUCTION.CycleNumber = ins[9]; + StepTime = ins[9]; } - if(ins[10]){ - Amplitude = ins[10]; - } - if(ins[11]){ - PulsePeriod = ins[11]; + if(ins[10] | ins[11]){ + Amplitude = ((uint16_t) (ins[10]) << 8) | (uint16_t) (ins[11]); } if(ins[12]){ - PulseWidth = ins[12]; + PulsePeriod = ins[12]; + } + if(ins[13]){ + PulseWidth = ins[13]; } break; } @@ -792,21 +788,14 @@ static void update_ZM_instruction(uint8 *ins) { if(ins[5] | ins[6]){ VoltFinal = ((uint16_t) (ins[5]) << 8) | (uint16_t) (ins[6]); } - - if(ins[7]){ - Step = ins[7]; //don't care - } - if(ins[8]){ - StepTime = ins[8]; + if(ins[7] | ins[8]){ + Step = ((uint16_t) (ins[7]) << 8) | (uint16_t) (ins[8]); } if(ins[9]){ - INSTRUCTION.CycleNumber = ins[9]; //don't care + StepTime = ins[9]; } - if(ins[10]){ - Amplitude = ins[10]; - } - if(ins[11]){ - Increase = ins[11]; + if(ins[10] | ins[11]){ + Amplitude = ((uint16_t) (ins[10]) << 8) | (uint16_t) (ins[11]); } if(ins[12]){ PulseWidth = ins[12]; @@ -825,14 +814,14 @@ static void update_ZM_instruction(uint8 *ins) { VoltFinal = ((uint16_t) (ins[5]) << 8) | (uint16_t) (ins[6]); } - if(ins[7]){ - Step = ins[7]; - } - if(ins[8]){ - StepTime = ins[8]; + if(ins[7] | ins[8]){ + Step = ((uint16_t) (ins[7]) << 8) | (uint16_t) (ins[8]); } if(ins[9]){ - INSTRUCTION.CycleNumber = ins[9]; + StepTime = ins[9]; + } + if(ins[10]){ + INSTRUCTION.CycleNumber = ins[10]; } break; 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 0209773e7..db6f9f014 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 @@ -549,18 +549,18 @@ static void SWVCurve(){ // prepare the next output volt if (direction_up) { - if( counter == PulseWidth) Volt = Volt + (uint16_t)(Amplitude); - else if( counter == 2*PulseWidth ) Volt = Volt - (uint16_t)(Amplitude - Step); + if( counter == PulseWidth) Volt = Volt + Amplitude; + else if( counter == 2*PulseWidth ) Volt = Volt - (Amplitude - Step); else Volt = Volt; } else { - if( counter == PulseWidth) Volt = Volt - (uint16_t)(Amplitude); - else if( counter == 2*PulseWidth ) Volt = Volt + (uint16_t)(Amplitude - Step); + if( counter == PulseWidth) Volt = Volt - Amplitude; + else if( counter == 2*PulseWidth ) Volt = Volt + (Amplitude - Step); else Volt = Volt; } } - +/* //working DPV curve static void DPVCurve(){ static uint8_t ramp0; @@ -589,7 +589,7 @@ static void DPVCurve(){ if ( counter == 10) { counter = 1; - Volt1 = Volt1 + (uint16_t)(Step); + Volt1 = Volt1 + Step; } else { counter ++; @@ -598,9 +598,9 @@ static void DPVCurve(){ } +*/ -/* static void DPVCurve(){ static uint8_t counter; static uint16_t Volt1; @@ -616,8 +616,8 @@ static void DPVCurve(){ else direction_up = false; Volt1 = VoltOrigin; - if (direction_up) Volt2 = VoltOrigin + (uint16_t)(Amplitude); - else Volt2 = VoltOrigin - (uint16_t)(Amplitude); + if (direction_up) Volt2 = VoltOrigin + Amplitude; + else Volt2 = VoltOrigin - Amplitude; counter = 1; DACreset = false; @@ -649,22 +649,22 @@ static void DPVCurve(){ //check overflow/underflow and prepare for next output if (direction_up) { - if ( Volt1 + (uint16_t)(Step) < Volt1 ) Volt1 = 0xffff; - else Volt1 = Volt1 + (uint16_t)(Step); - if ( Volt2 + (uint16_t)(Step) < Volt2 ) Volt2 = 0xffff; - else Volt2 = Volt2 + (uint16_t)(Step); + if ( Volt1 + Step < Volt1 ) Volt1 = 0xffff; + else Volt1 = Volt1 + Step; + if ( Volt2 + Step < Volt2 ) Volt2 = 0xffff; + else Volt2 = Volt2 + Step; } else { - if ( Volt1 - (uint16_t)(Step) > Volt1 ) Volt1 = 0x0000; - else Volt1 = Volt1 - (uint16_t)(Step); - if ( Volt2 - (uint16_t)(Step) > Volt2) Volt2 = 0x0000; - else Volt2 = Volt2 - (uint16_t)(Step); + if ( Volt1 - Step > Volt1 ) Volt1 = 0x0000; + else Volt1 = Volt1 - Step; + if ( Volt2 - Step > Volt2) Volt2 = 0x0000; + else Volt2 = Volt2 - Step; } } -*/ + static void CVCurve(){ static uint8_t ramp0; @@ -733,8 +733,8 @@ static void CVCurve(){ - if(current_direction_up) outputV = outputV + (uint16_t)(Step); - else outputV = outputV - (uint16_t)(Step); + if(current_direction_up) outputV = outputV + Step; + else outputV = outputV - Step; }