[IV] try to report Vin
This commit is contained in:
+16
-16
@@ -45,15 +45,15 @@ static int32_t IT_Plot(WorkMode *WorkModeData) {
|
||||
|
||||
// read ADC current
|
||||
int32_t RealCurrent = 0, RealVolt = 0;
|
||||
// static uint8_t PreviousGain = GAIN_AUTO;
|
||||
static uint8_t PreviousGain = GAIN_AUTO;
|
||||
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
// if(INSTRUCTION.eliteFxn == IV_CURVE){
|
||||
// if (PreviousGain != INSTRUCTION.ADCGainLevel){
|
||||
// PreviousGain = INSTRUCTION.ADCGainLevel;
|
||||
// ReadCurrent(spi_ADC_rxbuf);
|
||||
// }
|
||||
// }
|
||||
if(INSTRUCTION.eliteFxn == IV_CURVE){
|
||||
if (PreviousGain != INSTRUCTION.ADCGainLevel){
|
||||
PreviousGain = INSTRUCTION.ADCGainLevel;
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
}
|
||||
}
|
||||
RealCurrent = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
}
|
||||
else{
|
||||
@@ -64,15 +64,15 @@ static int32_t IT_Plot(WorkMode *WorkModeData) {
|
||||
CURRENT_MODE->_MeasureData = RealCurrent;
|
||||
|
||||
|
||||
if(INSTRUCTION.eliteFxn == IV_CURVE){
|
||||
// RealVo = Vo - RealCurrent * 100R
|
||||
RealVolt = (INSTRUCTION.VoltConstant - DAC_ZERO)/5 - 200*(RealCurrent/1e6);
|
||||
|
||||
NotifyVolt[0] = (uint8_t) (RealVolt >> 24);
|
||||
NotifyVolt[1] = (uint8_t) ((RealVolt & 0x00FF0000) >> 16);
|
||||
NotifyVolt[2] = (uint8_t) ((RealVolt & 0x0000FF00) >> 8);
|
||||
NotifyVolt[3] = (uint8_t) (RealVolt & 0x000000FF);
|
||||
}
|
||||
// if(INSTRUCTION.eliteFxn == IV_CURVE){
|
||||
// // RealVo = Vo - RealCurrent * 100R
|
||||
// RealVolt = (INSTRUCTION.VoltConstant - DAC_ZERO)/5 - 200*(RealCurrent/1e6);
|
||||
//
|
||||
// NotifyVolt[0] = (uint8_t) (RealVolt >> 24);
|
||||
// NotifyVolt[1] = (uint8_t) ((RealVolt & 0x00FF0000) >> 16);
|
||||
// NotifyVolt[2] = (uint8_t) ((RealVolt & 0x0000FF00) >> 8);
|
||||
// NotifyVolt[3] = (uint8_t) (RealVolt & 0x000000FF);
|
||||
// }
|
||||
return RealCurrent;
|
||||
}
|
||||
|
||||
|
||||
+59
-9
@@ -48,10 +48,10 @@ static uint16_t OneWayVoltScan(IVMode *IV) {
|
||||
DAC_outputV(DACOutCode);
|
||||
|
||||
// end IV task if we reach INSTRUCTION.VoltFinal
|
||||
if (INSTRUCTION.VoltConstant >= IV->_VStop) {
|
||||
PeriodicEvent = false;
|
||||
DACReset = true;
|
||||
}
|
||||
// if (INSTRUCTION.VoltConstant >= IV->_VStop) {
|
||||
// PeriodicEvent = false;
|
||||
// DACReset = true;
|
||||
// }
|
||||
} else {
|
||||
|
||||
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - IV->_Step;
|
||||
@@ -73,14 +73,64 @@ static uint16_t OneWayVoltScan(IVMode *IV) {
|
||||
DAC_outputV(DACOutCode);
|
||||
|
||||
// end IV task if we reach INSTRUCTION.VoltFinal
|
||||
if (INSTRUCTION.VoltConstant <= IV->_VStop){
|
||||
PeriodicEvent = false;
|
||||
DACReset = true;
|
||||
// reset();
|
||||
}
|
||||
// if (INSTRUCTION.VoltConstant <= IV->_VStop){
|
||||
// PeriodicEvent = false;
|
||||
// DACReset = true;
|
||||
//// reset();
|
||||
// }
|
||||
}
|
||||
}
|
||||
return DACOutCode;
|
||||
}
|
||||
|
||||
static int32_t IV_Plot(IVMode *IV) {
|
||||
static uint8_t VoltCurrentSwitch = 0;
|
||||
|
||||
if(VoltCurrentSwitch < 5){
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
VoltCurrentSwitch ++;
|
||||
}
|
||||
else if(VoltCurrentSwitch == 5){
|
||||
// read current
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
}
|
||||
else{
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
IV->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
}
|
||||
VoltCurrentSwitch ++;
|
||||
}
|
||||
else if(VoltCurrentSwitch <10){
|
||||
// read volt
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
VoltCurrentSwitch++;
|
||||
}
|
||||
else if(VoltCurrentSwitch == 10){
|
||||
/** read battery voltage **/
|
||||
ReadVolt(spi_ADC_rxbuf);
|
||||
IV->MeasureVolt = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_VOLT, spi_ADC_rxbuf);
|
||||
VoltCurrentSwitch++;
|
||||
}
|
||||
else{
|
||||
VoltCurrentSwitch = 0;
|
||||
}
|
||||
|
||||
if (IV->_VOrigin < IV->_VStop) {
|
||||
if(IV_MeasureVolt >= IV->_VStop){
|
||||
PeriodicEvent = false;
|
||||
DACReset = true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(IV_MeasureVolt <= IV->_VStop){
|
||||
PeriodicEvent = false;
|
||||
DACReset = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -266,6 +266,7 @@ VoltOutMode *InitVoltOutMode(){
|
||||
/* IV Mode Data */
|
||||
typedef struct _IVMode{
|
||||
MEASURE;
|
||||
int32_t MeasureVolt;
|
||||
VOUT_PARA;
|
||||
LIMIT;
|
||||
}IVMode;
|
||||
@@ -273,8 +274,7 @@ typedef struct _IVMode{
|
||||
IVMode *InitIVMode(){
|
||||
IVMode *ret = malloc(sizeof(IVMode));
|
||||
ret->_MeasureData = 0;
|
||||
// ret->SetMeasureData = &_SetMeasureData;
|
||||
// ret->GetMeasureData = &_GetMeasureData;
|
||||
ret->MeasureVolt = INSTRUCTION.VoltOrigin ;
|
||||
|
||||
ret->_VoltOut = DAC_ZERO;
|
||||
ret->_VOrigin = INSTRUCTION.VoltOrigin;
|
||||
|
||||
+2
-1
@@ -191,7 +191,8 @@ static void EliteADCControl(WorkMode *WorkModeData) {
|
||||
if (CT.SampleRate_counter == INSTRUCTION.SampleRate - 1) {
|
||||
switch (INSTRUCTION.eliteFxn) {
|
||||
case IV_CURVE:{
|
||||
IT_Plot(WorkModeData);
|
||||
IV_Plot(WorkModeData->IV);
|
||||
// IT_Plot(WorkModeData);
|
||||
break;
|
||||
}
|
||||
case CV_CURVE:{
|
||||
|
||||
Reference in New Issue
Block a user