I had it already in the MPPT routine, but never got around to cleaning up the scan routine..
just noticed-- its wrongin the MPPT routine.. yikes..will send a file when I getit done..
the scan display is still messed up--I am working on that.. need to clean up alot of stuff. I have been working on a new drop-in replacement
that will have OTA and internet interactive so u can see remotely whats going on..
adafruit QT PY ESP32-S2
lotta changes being made.. this new chip is a screamer-- 240 Mhz.. and the ADC is completely different.. so kinda busy..lol..
void doMPPT(){static int32_t cloudyTMR=4;
static int32_t WATTSmem=0;
static int32_t modeTMR=0;
static int32_t cloudyWATTSmem=0;
scanVitals();
if(board==MakeSkyBlue_30A){modeTMR--;
if(modeTMR<0){modeTMR=50;
if(pwmLEVEL>0)if(BATTi<=pwmLEVEL){mode=_MPPT;}
else mode=_PWM;}}
cloudyTMR--;
if(cloudyTMR<0){cloudyTMR=20; //look for rapid fade or rise
if(abs(WATTS-cloudyWATTSmem)>
(cloudyWATTSmem+((cloudyWATTSmem*5)/10))){intFlagSCAN=true; //sun cloudy up/dn
cloudyWATTSmem=WATTS;}}
//determine mode--bulk or float
if(BATTv>BULKv)bulkMODE=false;
if(BATTv<(FLOATv*9)/10)bulkMODE=true; //10% drop from float v
if(PVv>BATTv){//do MPPT
if(((bulkMODE==true) && (BATTv<BULKv))||
((bulkMODE==false) && (BATTv<FLOATv))){//dither around sweetSpot
//scanVitals();
if(WATTS<WATTSmem)DIR=!DIR;
if(DIR==UP)PWM++;
if(DIR==DN)PWM--;
if(mode==_MPPT){if(PWM<peakPWM-20){PWM=peakPWM;
DIR=!DIR;}
if(PWM>(freq[f_idx]-2)){PWM=peakPWM;
DIR=!DIR;}}
if(mode==_PWM){if(PWM<127){PWM=127;
DIR=!DIR;}
if(PWM>254){PWM=254;
DIR=!DIR;}}
if(degHOT>32)PWM=peakPWM/4;
if(degHOT>34)PWM=2;
if(WATTS>maxChargeAmps)PWM=PWM-(PWM/8);
if(mode==_MPPT){driveFETs(f_idx,PWM);}
if(mode==_PWM)analogWrite(PWMdrv,254);
WATTSmem=WATTS;}
else driveFETs(f_idx,2);
}
else analogWrite(PWMdrv,LOW);
}