[IV] Try AutoGain
This commit is contained in:
+2
-1
@@ -725,7 +725,8 @@ static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_
|
||||
// return real current to controller
|
||||
else if(ADCChannel == ADC_CH_CURRENT){
|
||||
|
||||
if ( (INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) {
|
||||
// if ( (INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) {
|
||||
if ( (INSTRUCTION.eliteFxn == CV_CURVE)) {
|
||||
// wait 0.1 sec until circuit stable => discard first data means wait 0.1 sec
|
||||
if(DiscardIVFirstData){
|
||||
DiscardIVFirstData ++;
|
||||
|
||||
+18
-4
@@ -88,6 +88,7 @@ static uint16_t OneWayVoltScan(IVMode *IV) {
|
||||
|
||||
static void IV_Plot(IVMode *IV) {
|
||||
static uint8_t VoltCurrentSwitch = 0;
|
||||
static uint8_t PreviousGain = GAIN_200R;
|
||||
uint16_t ADC_measure = 0;
|
||||
|
||||
if(VoltCurrentSwitch < 5){
|
||||
@@ -96,10 +97,23 @@ static void IV_Plot(IVMode *IV) {
|
||||
}
|
||||
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 ++;
|
||||
|
||||
if(INSTRUCTION.AutoGainEnable){
|
||||
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
while(PreviousGain != INSTRUCTION.ADCGainLevel){
|
||||
PreviousGain = INSTRUCTION.ADCGainLevel;
|
||||
IV->_MeasureData = AutoGainReadCurrent(spi_ADC_rxbuf);
|
||||
}
|
||||
}
|
||||
else{
|
||||
ReadCurrent(spi_ADC_rxbuf);
|
||||
IV->_MeasureData = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user