don't measure battery when run mode
This commit is contained in:
+212
-120
@@ -102,74 +102,150 @@ static void DACenable(uint8_t afterRead){
|
||||
static void CC_Plot(void)
|
||||
{
|
||||
static uint8_t ADCSwitch = 0;
|
||||
static uint8_t BatSwitch = 0;
|
||||
static int32_t VoltData = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (ADCSwitch == 0) { /**read Iin(buffer),read V**/
|
||||
if (instru.AutoGainEnable) {
|
||||
MEAS_CURR(wm) = AutoGainReadIin(spi_ADC_rxbuf);
|
||||
AutoGainChangeIin(MEAS_CURR(wm));
|
||||
} else {
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
MEAS_CURR(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
if (lastIinADCGainLevel != instru.ADCGainLevel) {
|
||||
IinADCGainControl(instru.ADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
if (record_flag == false) {
|
||||
static int recordCount = 0;
|
||||
recordCount++;
|
||||
if (recordCount == 2) {
|
||||
record_flag = true;
|
||||
recordCount = 0;
|
||||
}
|
||||
} else {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
}
|
||||
DACenable(AFTER_READ_I);
|
||||
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
ADCSwitch++;
|
||||
} else if(ADCSwitch == 1) { /**read V**/
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
ADCSwitch++;
|
||||
} else if(ADCSwitch == 2) { /**read V(buffer),read Iin**/
|
||||
if (VOLT_SW(wm) == 0x01 || VOLT_SW(wm) == 0x02) {
|
||||
if (instru.VinAutoGainEnable) {
|
||||
MEAS_VIN(wm) = AutoGainReadVin(spi_ADC_rxbuf);
|
||||
AutoGainChangeVin(MEAS_VIN(wm));
|
||||
// if (batteryCheck_flag) {
|
||||
// if (BatSwitch == 0) {
|
||||
// if (ADCSwitch == 0) { /**read Iin(buffer),read bat**/
|
||||
// if (instru.AutoGainEnable) {
|
||||
// MEAS_CURR(wm) = AutoGainReadIin(spi_ADC_rxbuf);
|
||||
// AutoGainChangeIin(MEAS_CURR(wm));
|
||||
// } else {
|
||||
// ReadADCIin(spi_ADC_rxbuf);
|
||||
// MEAS_CURR(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
// if (lastIinADCGainLevel != instru.ADCGainLevel) {
|
||||
// IinADCGainControl(instru.ADCGainLevel);
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// if (record_flag == false) {
|
||||
// static int recordCount = 0;
|
||||
// recordCount++;
|
||||
// if (recordCount == 2) {
|
||||
// record_flag = true;
|
||||
// recordCount = 0;
|
||||
// }
|
||||
// } else {
|
||||
// InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
// }
|
||||
// DACenable(AFTER_READ_I);
|
||||
//
|
||||
// ReadADCBat(spi_ADC_rxbuf);
|
||||
// BatSwitch++;
|
||||
// } else if(ADCSwitch == 1 || ADCSwitch == 3) { /**read Bat**/
|
||||
// ReadADCBat(spi_ADC_rxbuf);
|
||||
// BatSwitch++;
|
||||
// } else if(ADCSwitch == 2) { /**read V(buffer),read bat**/
|
||||
// if (VOLT_SW(wm) == 0x01 || VOLT_SW(wm) == 0x02) {
|
||||
// if (instru.VinAutoGainEnable) {
|
||||
// MEAS_VIN(wm) = AutoGainReadVin(spi_ADC_rxbuf);
|
||||
// AutoGainChangeVin(MEAS_VIN(wm));
|
||||
// } else {
|
||||
// ReadADCVolt(VOLT_SW(wm));
|
||||
// MEAS_VIN(wm) = DecodeADCValue(instru.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
// if (lastVinADCGainLevel != instru.VinADCGainLevel) {
|
||||
// VinADCGainControl(instru.VinADCGainLevel);
|
||||
// record_flag = false;
|
||||
// }
|
||||
// }
|
||||
// VoltData = MEAS_VIN(wm);
|
||||
// } else if (VOLT_SW(wm) == 0x00) {
|
||||
// ReadADCVolt(VOLT_SW(wm));
|
||||
// MEAS_VOUT(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
// VoltData = MEAS_VOUT(wm);
|
||||
// }
|
||||
//
|
||||
// if (instru.VoViSwitch == 0x02) {
|
||||
// int32_t Vscan = (Vset / 200 - MEAS_VIN(wm));
|
||||
// Vscan = (int32_t)(Vscan);//[1uV]
|
||||
// InputNotify(NOTIFY_VOLT, Vscan);
|
||||
// } else {
|
||||
// InputNotify(NOTIFY_VOLT, VoltData);
|
||||
// }
|
||||
// DACenable(AFTER_READ_V);
|
||||
//
|
||||
// ReadADCBat(spi_ADC_rxbuf);
|
||||
// BatSwitch++;
|
||||
// }
|
||||
// } else if(BatSwitch == 1) {
|
||||
// ReadADCBat(spi_ADC_rxbuf);
|
||||
// BatSwitch++;
|
||||
// } else if(BatSwitch == 2) {
|
||||
// headstage_battery_volt();
|
||||
// ReadADCIin(spi_ADC_rxbuf);
|
||||
// batteryCheck_flag = false;
|
||||
// BatSwitch = 0;
|
||||
// ADCSwitch = 3;
|
||||
// }
|
||||
// } else {
|
||||
BatSwitch = 0;
|
||||
if (ADCSwitch == 0) { /**read Iin(buffer),read V**/
|
||||
if (instru.AutoGainEnable) {
|
||||
MEAS_CURR(wm) = AutoGainReadIin(spi_ADC_rxbuf);
|
||||
AutoGainChangeIin(MEAS_CURR(wm));
|
||||
} else {
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
MEAS_VIN(wm) = DecodeADCValue(instru.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
if (lastVinADCGainLevel != instru.VinADCGainLevel) {
|
||||
VinADCGainControl(instru.VinADCGainLevel);
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
MEAS_CURR(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
if (lastIinADCGainLevel != instru.ADCGainLevel) {
|
||||
IinADCGainControl(instru.ADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
VoltData = MEAS_VIN(wm);
|
||||
} else if (VOLT_SW(wm) == 0x00) {
|
||||
if (record_flag == false) {
|
||||
static int recordCount = 0;
|
||||
recordCount++;
|
||||
if (recordCount == 2) {
|
||||
record_flag = true;
|
||||
recordCount = 0;
|
||||
}
|
||||
} else {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
}
|
||||
DACenable(AFTER_READ_I);
|
||||
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
MEAS_VOUT(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
VoltData = MEAS_VOUT(wm);
|
||||
ADCSwitch++;
|
||||
} else if(ADCSwitch == 1) { /**read V**/
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
ADCSwitch++;
|
||||
} else if(ADCSwitch == 2) { /**read V(buffer),read Iin**/
|
||||
if (VOLT_SW(wm) == 0x01 || VOLT_SW(wm) == 0x02) {
|
||||
if (instru.VinAutoGainEnable) {
|
||||
MEAS_VIN(wm) = AutoGainReadVin(spi_ADC_rxbuf);
|
||||
AutoGainChangeVin(MEAS_VIN(wm));
|
||||
} else {
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
MEAS_VIN(wm) = DecodeADCValue(instru.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
if (lastVinADCGainLevel != instru.VinADCGainLevel) {
|
||||
VinADCGainControl(instru.VinADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
VoltData = MEAS_VIN(wm);
|
||||
} else if (VOLT_SW(wm) == 0x00) {
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
MEAS_VOUT(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
VoltData = MEAS_VOUT(wm);
|
||||
}
|
||||
|
||||
if (instru.VoViSwitch == 0x02) {
|
||||
int32_t Vscan = (Vset / 200 - MEAS_VIN(wm));
|
||||
Vscan = (int32_t)(Vscan);//[1uV]
|
||||
InputNotify(NOTIFY_VOLT, Vscan);
|
||||
} else {
|
||||
InputNotify(NOTIFY_VOLT, VoltData);
|
||||
}
|
||||
DACenable(AFTER_READ_V);
|
||||
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADCSwitch++;
|
||||
} else if (ADCSwitch == 3) { /**read Iin**/
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
|
||||
if (instru.VoViSwitch == 0x02) {
|
||||
int32_t Vscan = (Vset / 200 - MEAS_VIN(wm));
|
||||
Vscan = (int32_t)(Vscan);//[1uV]
|
||||
InputNotify(NOTIFY_VOLT, Vscan);
|
||||
} else {
|
||||
InputNotify(NOTIFY_VOLT, VoltData);
|
||||
}
|
||||
DACenable(AFTER_READ_V);
|
||||
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADCSwitch++;
|
||||
} else if (ADCSwitch == 3) { /**read Iin**/
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
static void IT_Plot(void)
|
||||
@@ -177,36 +253,44 @@ static void IT_Plot(void)
|
||||
static uint8_t ADCSwitch = 0;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (ADCSwitch == 0) { /**read Iin(buffer)**/
|
||||
if (instru.AutoGainEnable) {
|
||||
MEAS_CURR(wm) = AutoGainReadIin(spi_ADC_rxbuf);
|
||||
AutoGainChangeIin(MEAS_CURR(wm));
|
||||
} else {
|
||||
// if (batteryCheck_flag) {
|
||||
// EliteADCBattery();
|
||||
// if (!batteryCheck_flag) {
|
||||
// ReadADCIin(spi_ADC_rxbuf);
|
||||
// ADCSwitch = 2;
|
||||
// }
|
||||
// } else {
|
||||
if (ADCSwitch == 0) { /**read Iin(buffer)**/
|
||||
if (instru.AutoGainEnable) {
|
||||
MEAS_CURR(wm) = AutoGainReadIin(spi_ADC_rxbuf);
|
||||
AutoGainChangeIin(MEAS_CURR(wm));
|
||||
} else {
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
MEAS_CURR(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
if (lastIinADCGainLevel != instru.ADCGainLevel) {
|
||||
IinADCGainControl(instru.ADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
if (record_flag == false) {
|
||||
static int recordCount = 0;
|
||||
recordCount++;
|
||||
if (recordCount == 2) {
|
||||
record_flag = true;
|
||||
recordCount = 0;
|
||||
}
|
||||
} else {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
}
|
||||
ADCSwitch++;
|
||||
} else if (ADCSwitch == 1) { /**read Iin**/
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
MEAS_CURR(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
if (lastIinADCGainLevel != instru.ADCGainLevel) {
|
||||
IinADCGainControl(instru.ADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
ADCSwitch++;
|
||||
} else if(ADCSwitch == 2) { /**read Iin**/
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
if (record_flag == false) {
|
||||
static int recordCount = 0;
|
||||
recordCount++;
|
||||
if (recordCount == 2) {
|
||||
record_flag = true;
|
||||
recordCount = 0;
|
||||
}
|
||||
} else {
|
||||
InputNotify(NOTIFY_CURRENT, MEAS_CURR(wm));
|
||||
}
|
||||
ADCSwitch++;
|
||||
} else if (ADCSwitch == 1) { /**read Iin**/
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADCSwitch++;
|
||||
} else if(ADCSwitch == 2) { /**read Iin**/
|
||||
ReadADCIin(spi_ADC_rxbuf);
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
static void VT_Plot(void)
|
||||
@@ -215,45 +299,53 @@ static void VT_Plot(void)
|
||||
static int32_t VoltData;
|
||||
void *wm = wm_get();
|
||||
|
||||
if (ADCSwitch == 0) { /**read V(buffer)**/
|
||||
if (VOLT_SW(wm) == 0x01 || VOLT_SW(wm) == 0x02) {
|
||||
if (instru.VinAutoGainEnable) {
|
||||
MEAS_VIN(wm) = AutoGainReadVin(spi_ADC_rxbuf);
|
||||
AutoGainChangeVin(MEAS_VIN(wm));
|
||||
} else {
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
MEAS_VIN(wm) = DecodeADCValue(instru.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
// if (batteryCheck_flag) {
|
||||
// EliteADCBattery();
|
||||
// if (!batteryCheck_flag) {
|
||||
// ReadADCVolt(VOLT_SW(wm));
|
||||
// ADCSwitch = 2;
|
||||
// }
|
||||
// } else {
|
||||
if (ADCSwitch == 0) { /**read V(buffer)**/
|
||||
if (VOLT_SW(wm) == 0x01 || VOLT_SW(wm) == 0x02) {
|
||||
if (instru.VinAutoGainEnable) {
|
||||
MEAS_VIN(wm) = AutoGainReadVin(spi_ADC_rxbuf);
|
||||
AutoGainChangeVin(MEAS_VIN(wm));
|
||||
} else {
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
MEAS_VIN(wm) = DecodeADCValue(instru.VinADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
|
||||
if (lastVinADCGainLevel != instru.VinADCGainLevel) {
|
||||
VinADCGainControl(instru.VinADCGainLevel);
|
||||
record_flag = false;
|
||||
if (lastVinADCGainLevel != instru.VinADCGainLevel) {
|
||||
VinADCGainControl(instru.VinADCGainLevel);
|
||||
record_flag = false;
|
||||
}
|
||||
}
|
||||
VoltData = MEAS_VIN(wm);
|
||||
} else if (VOLT_SW(wm) == 0x00) {
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
MEAS_VOUT(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
VoltData = MEAS_VOUT(wm);
|
||||
}
|
||||
VoltData = MEAS_VIN(wm);
|
||||
} else if (VOLT_SW(wm) == 0x00) {
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
MEAS_VOUT(wm) = DecodeADCValue(instru.ADCGainLevel, ADC_CH_DAC, spi_ADC_rxbuf);
|
||||
VoltData = MEAS_VOUT(wm);
|
||||
}
|
||||
|
||||
if (record_flag == false) {
|
||||
static int recordCount = 0;
|
||||
recordCount++;
|
||||
if (recordCount == 2) {
|
||||
record_flag = true;
|
||||
recordCount = 0;
|
||||
if (record_flag == false) {
|
||||
static int recordCount = 0;
|
||||
recordCount++;
|
||||
if (recordCount == 2) {
|
||||
record_flag = true;
|
||||
recordCount = 0;
|
||||
}
|
||||
} else {
|
||||
InputNotify(NOTIFY_VOLT, VoltData);
|
||||
}
|
||||
} else {
|
||||
InputNotify(NOTIFY_VOLT, VoltData);
|
||||
ADCSwitch++;
|
||||
} else if (ADCSwitch == 1) { /**read V**/
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
ADCSwitch++;
|
||||
} else if (ADCSwitch == 2) { /**read V**/
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
ADCSwitch++;
|
||||
} else if (ADCSwitch == 1) { /**read V**/
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
ADCSwitch++;
|
||||
} else if (ADCSwitch == 2) { /**read V**/
|
||||
ReadADCVolt(VOLT_SW(wm));
|
||||
ADCSwitch = 0;
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
static void cali_IT_plot(void) {
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@
|
||||
|
||||
#define VERSION_DATE_YEAR 21
|
||||
#define VERSION_DATE_MONTH 3
|
||||
#define VERSION_DATE_DAY 5
|
||||
#define VERSION_DATE_HOUR 12
|
||||
#define VERSION_DATE_MINUTE 15
|
||||
#define VERSION_DATE_DAY 8
|
||||
#define VERSION_DATE_HOUR 10
|
||||
#define VERSION_DATE_MINUTE 1
|
||||
|
||||
// this is NOT the version hash !!
|
||||
// it's the last version hash
|
||||
|
||||
+13
@@ -191,6 +191,19 @@ static void SimpleBLEPeripheral_performPeriodicTask(void) {
|
||||
}
|
||||
}
|
||||
|
||||
//battery counter
|
||||
// GPT.BatteryADCCounter = GPT.BatteryADCCounter + GPT.DeltaGptimerCounter;
|
||||
// GPT.BatteryCheckCounter = GPT.BatteryCheckCounter + GPT.DeltaGptimerCounter;
|
||||
// if(GPT.BatteryCheckCounter >= 50000){
|
||||
// GPT.BatteryCheckCounter -= 50000; //To get right time
|
||||
// batteryCheck_flag = true;
|
||||
// }
|
||||
//
|
||||
// uint16_t bat = ((uint16_t)(NotifyVoltBat[2]) << 8 & 0xFF00 ) | ((uint16_t)(NotifyVoltBat[3]) & 0x00FF);
|
||||
// if( bat < 768 && bat > 20){
|
||||
// PIN15_setOutputValue(enable_5v, 0);
|
||||
// }
|
||||
|
||||
//ADC counter
|
||||
GPT.SampleRateCounter = GPT.SampleRateCounter + GPT.DeltaGptimerCounter;
|
||||
if(GPT.SampleRateCounter >= instru.sampleRate){
|
||||
|
||||
Reference in New Issue
Block a user