150V 45A MPPT - roll your own


Author Message
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1425
Posted: 11:42pm 16 Nov 2023      

something like this:

void sanity_check()
 {
 // check if battery connected, solar input exists, determine tracking mode, etc.
 // this is called once a second
 //

 // check for non zero current values once a minute, only in NIGHT mode and only once an hour when in night mode
 // if there is, increment cal_sensor_count
 // when it gets to 60, zero it and recalibrate
 //  
 int i;
 if (timeout_check(6,( (track_mode == NIGHT) && ( (fabs(Iin) > 0.1) || (fabs(Iout) > 0.1) )))
   {
     cal_sensor_count ++;
     if (cal_sensor_count > 60)
       {
         cal_sensor_count = 0;
         i = adc_average(IIN,25000);    // get input current sensor offset
         nvd.z_iin = i;                 // save it
         i = adc_average(IOUT,25000);   // etc.
         nvd.z_iout = i;
         nv();                         // write to non volatile ram
       }
   }
..
..