150V 45A MPPT - roll your own


Author Message
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1425
Posted: 12:40am 18 Nov 2023      

done and tested.

this will recal the current sensor zero every 60 minutes.
It "costs" a few seconds of no charging when it runs.

This version is for the I2C LCD builds


mpptv5_BV_tempco_I2C_night_recal (2).zip


I tested it by having the serial console open and I check the
zero offsets for the two current sensors.
In my case they are 127 and 124 counts for the input and output sensors

I then applied a 1 Amp current through a sensor, using an isolated supply.
This immediately adds 1 Amp to the displayed value.
Then when recal is done, that 1 Amp is removed and not surprisingly
the zero offset have changed to allow for that 1 Amp

Later, I removed the 1 Amp and again recal sorted out the zero offset.

For those who want to play with this, each time the recal code is run, the menu is refeshed on the console so that means we can see that it ran and we can see the new values.

The code I added is


// this will return true once a minute, so with the counter it will run once an hour
 // if night mode, easy, just calibrate
 // if not night mode, stop the converter, wait a bit, then cal. and then re-enable back into absorb mode
 // mppt mode will be enabled automatically if needed
 //
 if ( timeout_check(6,1))
   {
     cal_sensor_count ++;
     if (cal_sensor_count > 60)           // should be 60 for an hour. testing will have it at 2 or something
       {
         cal_sensor_count = 0;           // one hour is up time to recal current sensor zero points
         if (track_mode != NIGHT)
           {
             //stop it
             buck_stop(3);
             track_mode = NIGHT;
             //wait. maybe need this to let caps equalise with battery and solar inputs
             dlay(2000);
             //recal
             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
             //restart, set 60 sec timer for mppt close to 60 seconds to more quickly get to mppt scan
             one_min = 55;
           }
         else
           {
             // it's night mode  
             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
           }
       }
   }


inside the sanity_check() code block