Compare commits

..

7 Commits

Author SHA1 Message Date
YiChin 0259d3ec61 TODO: delete auto gain 2019-11-11 19:11:12 +08:00
YiChin 8bc43f1bb0 [CC] This is a stable version 2019-11-11 11:06:55 +08:00
weiting2 50acc23eb1 [CC mode] read Vin 2019-11-11 10:52:21 +08:00
YiChin a26bad68a6 [CC] everything well, return Vin works ^^ 2019-11-11 10:46:13 +08:00
weiting2 f5796e8ac5 [CC mode] read Vin 2019-11-11 10:26:13 +08:00
YiChin c862e6790f [CC] everything well, NEED RETURN VIN 2019-11-08 17:38:55 +08:00
YiChin fb43ec6ac3 [CC] Vin + V_(Iin-GND) = battery V 2019-11-08 16:09:09 +08:00
8 changed files with 81 additions and 363 deletions
@@ -6,7 +6,7 @@ static void CCModeDACControl(int32_t IUC_Measure_Difference);
static int32_t CCModeReadCurrent(CCMode *CC){
static bool IVSwitch = false;
static uint8_t VoltCurrentSwitch = 0;
CCModeDACEnable = 1; // This flag will control DAC working
@@ -14,8 +14,15 @@ static int32_t CCModeReadCurrent(CCMode *CC){
CCCurrent2IUC(CC);
// decode ADC value and put it into notify buffer
if(IVSwitch){
IVSwitch = false;
// Use 9-th measure value as real-measure value
// because some value in the begin are garbage
if(VoltCurrentSwitch < 9){
ReadCurrent(spi_ADC_rxbuf);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch == 9){
// read current
if(INSTRUCTION.AutoGainEnable){
CC->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
}
@@ -23,21 +30,38 @@ static int32_t CCModeReadCurrent(CCMode *CC){
ReadCurrent(spi_ADC_rxbuf);
CC->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch <18){
// read volt
ReadVolt(spi_ADC_rxbuf);
VoltCurrentSwitch++;
}
else if(VoltCurrentSwitch == 18){
// read volt
ReadVolt(spi_ADC_rxbuf);
CC->BatteryV = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
// if Iin connect to battery +, Vout connect to battery -
// CC->BatteryV = CC->BatteryV - (CC->value - CC_ZERO_POINT)*10/1e5; // I_set * 10R = V_Iin2GND (mA * ohm)
// if Iin connect to battery -, Vout connect to battery +
CC->BatteryV = CC->BatteryV + (CC->value - CC_ZERO_POINT)*10/1e5; // I_set * 10R = V_Iin2GND (mA * ohm)
VoltCurrentSwitch++;
}
else{
IVSwitch = true;
/** read battery voltage **/
// read ADC volt
ReadVolt(spi_ADC_rxbuf);
// decode ADC value and put it into notify buffer
CC->BatteryV = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
VoltCurrentSwitch = 0;
}
NotifyCurrent[0] = (uint8_t) (CC->_MeasureData >> 24);
NotifyCurrent[1] = (uint8_t) ((CC->_MeasureData & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((CC->_MeasureData & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (CC->_MeasureData & 0x000000FF);
// /** read battery voltage **/
// // read ADC volt
// ReadVolt(spi_ADC_rxbuf);
//
// // decode ADC value and put it into notify buffer
// CC->BatteryV = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
//
NotifyVolt[0] = (uint8_t) (CC->BatteryV >> 24);
NotifyVolt[1] = (uint8_t) ((CC->BatteryV & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((CC->BatteryV & 0x0000FF00) >> 8);
@@ -59,24 +83,29 @@ static int32_t CCModeVoltOut(CCMode *CC){
MeasureCurrent = CC->_MeasureData;
CCModeDACControl(IUCCurrent - MeasureCurrent);
// NotifyCurrent[0] = (uint8_t) (IUCCurrent >> 24);
// NotifyCurrent[1] = (uint8_t) ((IUCCurrent & 0x00FF0000) >> 16);
// NotifyCurrent[2] = (uint8_t) ((IUCCurrent & 0x0000FF00) >> 8);
// NotifyCurrent[3] = (uint8_t) (IUCCurrent & 0x000000FF);
//
// NotifyImpedance[0] = (uint8_t) (MeasureCurrent >> 24);
// NotifyImpedance[1] = (uint8_t) ((MeasureCurrent & 0x00FF0000) >> 16);
// NotifyImpedance[2] = (uint8_t) ((MeasureCurrent & 0x0000FF00) >> 8);
// NotifyImpedance[3] = (uint8_t) (MeasureCurrent & 0x000000FF);
NotifyCurrent[0] = (uint8_t) (IUCCurrent >> 24);
NotifyCurrent[1] = (uint8_t) ((IUCCurrent & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((IUCCurrent & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (IUCCurrent & 0x000000FF);
NotifyImpedance[0] = (uint8_t) (MeasureCurrent >> 24);
NotifyImpedance[1] = (uint8_t) ((MeasureCurrent & 0x00FF0000) >> 16);
NotifyImpedance[2] = (uint8_t) ((MeasureCurrent & 0x0000FF00) >> 8);
NotifyImpedance[3] = (uint8_t) (MeasureCurrent & 0x000000FF);
// DACCode2Real2Notify(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
// if(IUCCurrent > 1000){
// ADCRealVolt = 2*(INSTRUCTION.VoltConstant - 25000)/10 - IUCCurrent*200/1e6;
// }
// else{
// ADCRealVolt = 2*(INSTRUCTION.VoltConstant - 25000)/10 - IUCCurrent*200/1e7;
// CC->BatteryV = 2*(INSTRUCTION.VoltConstant - 25000)/10 - IUCCurrent*200/1e7;
// }
// NotifyVolt[0] = (uint8_t) (CC->BatteryV >> 24);
// NotifyVolt[1] = (uint8_t) ((CC->BatteryV & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t) ((CC->BatteryV & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t) (CC->BatteryV & 0x000000FF);
CCModeDACEnable = 0;
return MeasureCurrent;
}
@@ -109,11 +138,6 @@ static void CCModeDACControl(int32_t IUC_Measure_Difference){
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + step;
}
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
// NotifyCurrent[0] = (uint8_t) ( step >> 24);
// NotifyCurrent[1] = (uint8_t) (( step & 0x00FF0000) >> 16);
// NotifyCurrent[2] = (uint8_t) (( step & 0x0000FF00) >> 8);
// NotifyCurrent[3] = (uint8_t) ( step & 0x000000FF);
}
// XXX : should we reset DAC output after STOP?
@@ -205,5 +229,4 @@ static void CCCurrent2IUC(CCMode *CC){
// return CurrentUserCode;
//}
#endif
@@ -29,7 +29,7 @@
*/
#define BOARD_EARTH
#define BOARD_MERCURY
typedef struct _formula{
@@ -141,8 +141,8 @@ struct _correction{
.ADC_current[0].coeff = 30022512,
.ADC_current[0].offset = -729552647201,
.ADC_current[1].coeff = 658398533,
.ADC_current[1].offset = -16001498741131,
.ADC_current[1].coeff = 658398533000,
.ADC_current[1].offset = -16001498741131000,
.ADC_current[2].coeff = 30908351000,
.ADC_current[2].offset = -746548614824000,
@@ -172,8 +172,8 @@ struct _correction{
.ADC_current[1].coeff = 652738209,
.ADC_current[1].offset = -15767733896990,
.ADC_current[2].coeff = 30959456,
.ADC_current[2].offset = -748026885843,
.ADC_current[2].coeff = 30959456000,
.ADC_current[2].offset = -748026885843000,
.DAC2RealV.coeff = (-18880478),
.DAC2RealV.offset = 629012735316,
@@ -507,34 +507,6 @@ struct _correction{
};
#endif
#ifdef BOARD_WATER_STAR
{
.ADC_volt.coeff = (-6259808),
.ADC_volt.offset = 102009860128,
.ADC_current[0].coeff = 31335917,
.ADC_current[0].offset = (-511426612252),
.ADC_current[1].coeff = 658172815,
.ADC_current[1].offset = (-10738251896209),
.ADC_current[2].coeff = 31482687000,
.ADC_current[2].offset = (-513650531545000),
.DAC2RealV.coeff = (-10548297),
.DAC2RealV.offset = 562611756757,
.Usercode2DAC.coeff = (-10500262),
.Usercode2DAC.offset = 559630236100,
.Gain0Boundary[0] = 0x5D96,
.Gain0Boundary[1] = 0x5DD9,
.Gain1Boundary[0] = 0x57CD,
.Gain1Boundary[1] = 0x639F
};
#endif
#ifdef BOARD_MARS
{
.ADC_volt.coeff = (-6270623),
@@ -37,9 +37,6 @@ static int32_t IT_Plot(WorkMode *WorkModeData) {
#define CURRENT_MODE WorkModeData->IT
break;
}
case POTENTIAL_STATE:{
#define CURRENT_MODE WorkModeData->PS
}
default: {
#define CURRENT_MODE WorkModeData->IV
break;
@@ -15,8 +15,6 @@ static uint16_t VoltScan(WorkMode *WorkModeData) {
Voltage = DPVCurve(WorkModeData);
} else if (INSTRUCTION.eliteFxn == CV_CURVE) {
Voltage = CVCurve(WorkModeData->CV);
} else if (INSTRUCTION.eliteFxn == POTENTIAL_STATE ) {
Voltage = PSCurve(WorkModeData->PS);
}
// IV plot mode
@@ -74,69 +72,15 @@ static uint16_t OneWayVoltScan(IVMode *IV) {
DACOutCode = Usercode_Correction_to_DAC(DACUserCode);
DAC_outputV(DACOutCode);
// // end IV task if we reach INSTRUCTION.VoltFinal
// if (DACUserCode <= IV->_VStop){
// PeriodicEvent = false;
// DACReset = true;
// // reset();
// end IV task if we reach INSTRUCTION.VoltFinal
if (DACUserCode <= IV->_VStop){
PeriodicEvent = false;
DACReset = true;
// reset();
}
}
}
return DACOutCode;
}
static void IV_Plot(IVMode *IV) {
static uint8_t VoltCurrentSwitch = 0;
uint16_t ADC_measure = 0;
if(VoltCurrentSwitch < 5){
ReadCurrent(spi_ADC_rxbuf);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch == 5){
// read current
ReadCurrent(spi_ADC_rxbuf);
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
IV->_MeasureData = DecodeADCCurrent(INSTRUCTION.ADCGainLevel, ADC_measure);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch <9){
// read volt
ReadVolt(spi_ADC_rxbuf);
VoltCurrentSwitch++;
}
else if(VoltCurrentSwitch == 9){
/** read battery voltage **/
ReadVolt(spi_ADC_rxbuf);
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
IV->MeasureVolt = DecodeADCVolt(ADC_measure);
VoltCurrentSwitch++;
}
else{
VoltCurrentSwitch = 0;
}
NotifyCurrent[0] = (uint8_t) (IV->_MeasureData >> 24);
NotifyCurrent[1] = (uint8_t) ((IV->_MeasureData & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((IV->_MeasureData & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (IV->_MeasureData & 0x000000FF);
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->_VOrigin < IV->_VStop) {
if(IV->MeasureVolt >= (IV->_VStop - DAC_ZERO)/5){
PeriodicEvent = false;
DACReset = true;
}
}
else{
if(IV->MeasureVolt <= (IV->_VStop - DAC_ZERO)/5){
PeriodicEvent = false;
DACReset = true;
}
}
}
#endif
@@ -1,175 +0,0 @@
#ifndef ELITEPS
#define ELITEPS
static uint16_t PSCurve(PSMode *PS) {
static uint16_t DACOutCode;
static uint16_t DAC_ControlVolt;
static bool direction_up; // direction_up = true, if Vfinal > Vorigin
static bool current_direction_up; // current_direction_up = true, Vstep => positive. vice versa
// reset origin volt at the begin
if (DACReset) {
PS->_ControlVolt = PS->_VOrigin;
if (INSTRUCTION.VoltFinal > PS->_VOrigin) {
direction_up = true;
current_direction_up = true;
} else {
direction_up = false;
current_direction_up = false;
}
DACOutCode = Usercode_Correction_to_DAC(PS->_ControlVolt);
DAC_outputV(DACOutCode); // output VOLT_ORIGIN
DACReset = false;
return DACOutCode;
}
if (CT.StepTimeCounter == PS->_StepTime) {
// Decide next direction
if (direction_up) {
if (PS->_ControlVolt >= PS->_VStop) {
current_direction_up = false; // problem occurs when origin == 0000 final == ffff!!!!!!
} else if (PS->_ControlVolt <= PS->_VOrigin) {
current_direction_up = true;
if (PS->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
PS->_CycleNumber--;
}
} else {
if (PS->_ControlVolt <= PS->_VStop) {
current_direction_up = true; // problem occurs when origin == 0000 final == ffff!!!!!!
} else if (PS->_ControlVolt >= PS->_VOrigin) {
current_direction_up = false;
if (PS->_CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
PS->_CycleNumber--;
}
}
// Next output voltage
if (direction_up) {
if (current_direction_up) {
// PS->_ControlVolt overflow ?
if (PS->_ControlVolt + PS->_Step < PS->_ControlVolt) {
PS->_ControlVolt = PS->_VStop;
}
else if (PS->_ControlVolt + PS->_Step > PS->_VStop) {
PS->_ControlVolt =PS->_VStop;
}
else {
PS->_ControlVolt = PS->_ControlVolt + PS->_Step;
}
}
else {
// PS->_ControlVolt underflow ?
if (PS->_ControlVolt - PS->_Step > PS->_ControlVolt || PS->_ControlVolt > 60000) {
PS->_ControlVolt = PS->_VOrigin;
}
// reach Vorigin ?
else if (PS->_ControlVolt - PS->_Step < PS->_VOrigin) {
PS->_ControlVolt = PS->_VOrigin;
}
else {
PS->_ControlVolt = PS->_ControlVolt - PS->_Step;
}
}
}
else {
if (current_direction_up) {
if (PS->_ControlVolt + PS->_Step < PS->_ControlVolt) {
PS->_ControlVolt = PS->_VOrigin;
}
else if (PS->_ControlVolt + PS->_Step > PS->_VOrigin) {
PS->_ControlVolt = PS->_VOrigin;
}
else {
PS->_ControlVolt = PS->_ControlVolt + PS->_Step;
}
}
else {
if (PS->_ControlVolt - PS->_Step > PS->_ControlVolt || PS->_ControlVolt > 60000) {
PS->_ControlVolt = PS->_VStop ;
}
else if (PS->_ControlVolt - PS->_Step < PS->_VStop) {
PS->_ControlVolt = PS->_VStop;
}
else {
PS->_ControlVolt = PS->_ControlVolt - PS->_Step;
}
}
}
DACOutCode = PS->_MeasureVolt - PS->_ControlVolt;
DACOutCode = Usercode_Correction_to_DAC(DACOutCode);
DAC_outputV(DACOutCode);
}
DAC_ControlVolt = Usercode_Correction_to_DAC(PS->_ControlVolt);
return DAC_ControlVolt;
}
static void PS_Plot(PSMode* PS){
static uint8_t VoltCurrentSwitch = 0;
uint16_t ADC_measure = 0;
if(VoltCurrentSwitch < 5){
ReadCurrent(spi_ADC_rxbuf);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch == 5){
// read current
ReadCurrent(spi_ADC_rxbuf);
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
PS->_MeasureData = DecodeADCCurrent(INSTRUCTION.ADCGainLevel, ADC_measure);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch <9){
// read volt
ReadVolt(spi_ADC_rxbuf);
VoltCurrentSwitch++;
}
else if(VoltCurrentSwitch == 9){
/** read battery voltage **/
ReadVolt(spi_ADC_rxbuf);
ADC_measure = (uint16_t) (spi_ADC_rxbuf[0] << 8) | (uint16_t) (spi_ADC_rxbuf[1]);
PS->_MeasureVolt = DecodeADCVolt(ADC_measure);
VoltCurrentSwitch++;
}
else{
VoltCurrentSwitch = 0;
}
NotifyCurrent[0] = (uint8_t) (PS->_MeasureData >> 24);
NotifyCurrent[1] = (uint8_t) ((PS->_MeasureData & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((PS->_MeasureData & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (PS->_MeasureData & 0x000000FF);
// NotifyVolt[0] = (uint8_t) (PS->_MeasureVolt >> 24);
// NotifyVolt[1] = (uint8_t) ((PS->_MeasureVolt & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t) ((PS->_MeasureVolt & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t) (PS->_MeasureVolt & 0x000000FF);
// if (PS->_VOrigin < PS->_VStop) {
// if(PS->MeasureVolt >= (PS->_VStop - DAC_ZERO)/5){
// PeriodicEvent = false;
// DACReset = true;
// }
// }
// else{
// if(PS->MeasureVolt <= (PS->_VStop - DAC_ZERO)/5){
// PeriodicEvent = false;
// DACReset = true;
// }
// }
}
#endif
@@ -244,8 +244,6 @@ VoltOutMode *InitVoltOutMode(){
/* IV Mode Data */
typedef struct _IVMode{
MEASURE;
int32_t MeasureVolt;
VOUT_PARA;
LIMIT;
}IVMode;
@@ -255,7 +253,6 @@ IVMode *InitIVMode(){
ret->_MeasureData = 0;
ret->SetMeasureData = &_SetMeasureData;
ret->GetMeasureData = &_GetMeasureData;
ret->MeasureVolt = 0;
ret->_VoltOut = DAC_ZERO;
ret->_VOrigin = INSTRUCTION.VoltOrigin;
@@ -446,8 +443,8 @@ CCMode * InitCCMode(){
typedef struct _PS{
// measure
MEASURE; // circuit current
int16_t _ControlVolt;
int32_t _MeasureVolt;
int32_t ReferenceVolt;
VOUT_PARA;
}PSMode;
@@ -456,8 +453,7 @@ PSMode *InitPSMode(){
ret->_MeasureData = 0;
ret->SetMeasureData = &_SetMeasureData;
ret->GetMeasureData = &_GetMeasureData;
ret->_ControlVolt = INSTRUCTION.VoltOrigin;
ret->_MeasureVolt = INSTRUCTION.VoltOrigin;
ret->ReferenceVolt = 0;
ret->_VoltOut = DAC_ZERO; // 25000 is DAC_ZERO
ret->_VOrigin = INSTRUCTION.VoltOrigin;
@@ -514,9 +510,7 @@ void InitWorkMode(WorkMode *WM){
case CONSTANT_CURRENT:
WM->CC = InitCCMode();
break;
case POTENTIAL_STATE:
WM->PS = InitPSMode();
break;
default:
WM->VT = InitVTMode();
break;
@@ -567,12 +561,6 @@ void FreeWorkMode(WorkMode *WM){
WM->CC = NULL;
}
break;
case POTENTIAL_STATE:
if(WM->PS != NULL){
free(WM->PS);
WM->PS = NULL;
}
break;
default:
if(WM->IV != NULL){
free(WM->IV);
@@ -642,10 +642,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 void IV_Plot(IVMode *IV);
static void PS_Plot(PSMode *PS);
static int32_t IT_Plot(WorkMode *WorkModeData);
static int32_t IT_PlotIT_Plot(WorkMode *WorkModeData);
// the following fxn do the same thing
// IVCurve_T is called if Vorigin > Vfinal, vice versa
@@ -660,7 +657,6 @@ static void ramp_test();
static uint16_t DPVCurve(WorkMode *WorkModeData);
static uint16_t CVCurve(CVMode *CV);
static uint16_t SWVCurve(WorkMode *WorkModeData);
static uint16_t PSCurve(PSMode *PS);
static void reset();
static void Eliteinterrupt();
@@ -691,7 +687,6 @@ static void TurnOn10V();
#include "EliteCCMode.h"
#include "EliteIVCurve.h"
#include "EliteCVCurve.h"
#include "ElitePSCurve.h"
#include "EliteITCurve.h"
#include "EliteVTCurve.h"
#include "EliteZTCurve.h"
@@ -805,6 +800,7 @@ static void update_ZM_instruction(uint8 *ins) {
}
break;
}
case CV_CURVE: {
// CleanBuffer();
INSTRUCTION.eliteFxn = CV_CURVE;
@@ -871,42 +867,19 @@ static void update_ZM_instruction(uint8 *ins) {
}
case POTENTIAL_STATE: {
INSTRUCTION.eliteFxn = POTENTIAL_STATE;
DACReset = true;
INSTRUCTION.SampleRate = 1000;
if (ins[3] | ins[4]) {
INSTRUCTION.VoltOrigin = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
// INSTRUCTION.VoltOrigin = Usercode_Correction_to_DAC(INSTRUCTION.VoltOrigin);
}
if (ins[5] | ins[6]) {
INSTRUCTION.VoltFinal = ((uint16_t)(ins[5]) << 8) | (uint16_t)(ins[6]);
// INSTRUCTION.VoltFinal = Usercode_Correction_to_DAC(INSTRUCTION.VoltFinal);
}
if (ins[7] | ins[8]) {
INSTRUCTION.Step = ((uint16_t)(ins[7]) << 8) | (uint16_t)(ins[8]);
INSTRUCTION.Step = StepCode2DACcode(INSTRUCTION.Step);
}
if (ins[9]) {
INSTRUCTION.StepTime = ins[9];
INSTRUCTION.StepTime = OldStep2NewStepTime(INSTRUCTION.StepTime);
}
if (ins[10]) {
INSTRUCTION.CycleNumber = ins[10];
}
// // test
// not_buf[0] = ins[3];
// not_buf[1] = ins[4];
// not_buf[2] = ins[5];
// not_buf[3] = ins[6];
// SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
// test
not_buf[0] = ins[3];
not_buf[1] = ins[4];
not_buf[2] = ins[5];
not_buf[3] = ins[6];
// SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
break;
}
case CONSTANT_CURRENT:{
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
INSTRUCTION.SampleRate = 10;
INSTRUCTION.SampleRate = 6;
INSTRUCTION.ConstantCurrent = ( (uint32_t) (ins[3])<<24 | (uint32_t) (ins[4])<<16 | (uint32_t) (ins[5])<<8 | (uint32_t) (ins[6]) );
INSTRUCTION.NotifyRate = 1000;
// GetInstructionParameter(ins+2);
@@ -78,7 +78,6 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
(INSTRUCTION.eliteFxn == IT_CURVE) || \
(INSTRUCTION.eliteFxn == VT_CURVE) || \
(INSTRUCTION.eliteFxn == ZT_CURVE) || \
(INSTRUCTION.eliteFxn == POTENTIAL_STATE) || \
(INSTRUCTION.eliteFxn == CONSTANT_CURRENT) \
)
@@ -150,7 +149,7 @@ static void SimpleBLEPeripheral_performPeriodicTask(WorkMode *WorkModeData) {
}
static void EliteDACControl(WorkMode *WorkModeData) {
if ((INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE) || (INSTRUCTION.eliteFxn == POTENTIAL_STATE)) {
if ((INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) {
// output a certain voltage and put it into NotifyVolt
DACCode2Real2Notify(VoltScan(WorkModeData));
}
@@ -180,6 +179,7 @@ static void EliteDACControl(WorkMode *WorkModeData) {
}
CCModeVoltOut(WorkModeData->CC);
}
else{
// IT, VT need only ADC measure
return;
@@ -190,7 +190,7 @@ static void EliteADCControl(WorkMode *WorkModeData) {
if (CT.SampleRate_counter == INSTRUCTION.SampleRate - 1) {
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:{
IV_Plot(WorkModeData->IV);
IT_Plot(WorkModeData);
break;
}
case CV_CURVE:{
@@ -215,10 +215,6 @@ static void EliteADCControl(WorkMode *WorkModeData) {
CCModeReverseCurrent(WorkModeData->CC);
break;
}
case POTENTIAL_STATE:{
PS_Plot(WorkModeData->PS);
break;
}
default:{
IT_Plot(WorkModeData);
break;
@@ -237,7 +233,7 @@ static void EliteNotifyControl() {
SendNotify();
}
}
else if((INSTRUCTION.eliteFxn == CONSTANT_CURRENT) || (INSTRUCTION.eliteFxn == POTENTIAL_STATE)){
else if(INSTRUCTION.eliteFxn == CONSTANT_CURRENT){
if(CT.NotifyCounter == INSTRUCTION.NotifyRate){
SendNotify();
}