Monday, September 24, 2114

Solar MPPT controller

Last updated:  Nov 21, 2014

The SmartMPPT controller is a solar panel charge controller utilizing the Arduino IDE to allow for simple updating and modification. It is sized to support one or two 'large' solar panels (charge current up to 25A, and solar panel input up to 85v) supporting 12v, 24v, 32/36v, or 48v battery systems.  In its final form a wide range of charge profiles will be included, and when combined with the remote smartBMS module ( ) will allow advanced battery charge management capabilites (such as measuring battery acceptance rate) to assure not only a fully charge battery, but also protect it from overcharging (as well as chronic undercharging).

By using a module approach, multiple SmartMPPT controllers may be installed into a system to allow near unlimited solar capacity scaling.  In addition, each solar panel / mppt controller module will optimize power output independently - allowing optomial power production when say a port of your solar systems panels are shaded (highly important in movable structures, ala boats or RVs).  Simple CAT-5 cables connect the  SmartMPPT controller (s) allowing coordination of solar charging, as well as intelligent integration into other charging sources for the canBAT network (  )

Currently the 1st hardware design has been completed.  After fabrication the MPPT algorithm from Tim Nolan's efforts will be ported to proof the hardware.  From there will develop more advanced firmware to include concepts from the Smart Alternator Regulator ( such as configurable battery charge profiles, ASCII commands to allow customization w/o recompiling, as well as CAN protocols for communicaiton.  I am interested in experimenting with advanced MPPT algrosums, as well as other optomizaiton algrosiums (ala, self optomizing dead-time for the FETs)

Sunday, February 14, 2016

Continued refinement of the ATmega32M1 / ATmega64M1 support under Arduino IDE

Though slow, there has been progress in enabling the ATmega32M1 / ATmega64M1 uC inside the Arduino.  Today new Arduino IDE support files are available under the "Arduino Libs" resource tab above.  They corrects a few errors, and a new 'version' is available that is compatible with the latest Arduino IDE 1.6.7 without producing warning messages.

At this point we have demonstrated the basic of the porting effort, SPI has been demonstrated to functions - as well as I2C using one of the SoftI2C libs.  The advanced PCS (Power Stage Controller - think really smart PWM) is working, as is the amplified differential ADC inputs.  And a 1st step at utilizing the built in CAN subsystem was accomplished, via a rather ugly rough-n-ready porting of the Atmel AT90CAN lib.

Over the coming months I am looking to create a more 'Arduino like' library for the  CAN subsystem, and may also look at a like one for the PCS subsystem.  If anyone is interested in helping out, feel free to contact me!

Wednesday, July 8, 2015

Still here - how is YOUR summer?

Just a quick note:  am still here - and have not abandoned this project.    But have been kind of distracted with maintenance needed on our boat after it sat unattended for a full year.  Have also been working a bit on refinements to the Alternator Regulator project.

I do have the new v0.0.3 PCBs on hand, and parts for it all ready to solder up.  But with all that we have 'planned' for the summer there is a good chance I will not have much time to work on this for another month, or even more, but I am still interested in completing this MPPT platform.   So hand in there.

And if by chance there is anyone wanting to pitch in, I do have a couple of extra blank PCBs!


Friday, April 3, 2015

v0.0.3 posted

Today I posted v0.0.3 of the Arduino enabled solar MPPT controller.  Key changes include:

  1. Continued simplification of power supply - now primary switcher followed by LDO
  2. Inclusion of night-time 'dark' blocking FET
  3. Slight adjustments to FET driving traces, adding back in debug components.

I moved to a 13v switcher followed by a 5v LDO vs. the dual switcher in the last design.  Primary this gives a more stable voltage source into the ATmegaxxM1 for its ADCs - as well as providing a stronger VDD for the fet boost source.     In looking at the extra loss associated with the LDO, when fully active I calculate 175mW loss vs. perhaps 10 for a switching PS.  However this reduces down to the 5mW range when the uC is 'idle' or asleep - likely the in the same area as switcher (or even a little lower).  Given the uC can likely be placed into sleep for a large portion of time (most the peripherals work independently), am looking for low final loss.

Debugging has progresses enough that I thought it was time to add in a night-time blocking diode (using a FET for less loss).  The drive for this is pulled off of the boost ckt for bank-A, anytime that is working the blocking diode FET will get enabled.  It uses the intrinsic capacitance of the FET to keep enabled between pulses, while the 1M resistor provides a turn off after a period of inactivity.

I increased the trace widths of the FET drivers, and added in DC blocking capacitors, as well as 10K resistors between the drivers and the uC.  Idea hear is to provide SOME level of protection to the driver and uC while debugging code.  The final version of the PCB will have these removed.  And I likely will go to a 4-layer PCB for any final PCB as well.

Friday, March 20, 2015

Updated ATmega32M1 / ATmega64M1 support files for Arduino IDE

During debugging of the MPPT controller, I found a problem with the serial port code I adopted - resulting in random hangs while using Serial.Print() or Serial.Write() functions.  Today I posted corrected files (there was a logic error between the ::write object, and the interrupt handler).

I think the code can be cleaned up even more, and may do that later - perhaps using the current 1.6.1 files as a starting point.  But for now, do know there was a  bug which has been corrected.

Wednesday, March 4, 2015

ATmega32M1 and ATmega64M1 support with the new Arduino IDE 1.6.0

Update 2-14-2016:  There has been some fixes around ports usage - see readme.txt for details.  SPI is now demonstrated to work, and have been making progress in a CAN library. 

There are now 3 different 'versions' of the support files to use with different generations of the Arduino IDE, including the latest 1.6.7 w/o warning.

 March 4, 2015:
This morning I posted up new portings of the ATmega64M1 uC in several variations, as well as support for the ATmega32M1 uC - all enabled at the same time in the new Arduino IDE release 1.6.0

Look under the Arduino Libs resource tab above, and follow the links and readme for the Arduino 1.6.0 IDE.  In short, you will need to copy a subdirectory in its entirety to your local 'arduino' users folder, and you will still need to make some edits with the avrdude.cong file.  But once done, you will find new 'board types' available for the ATmega64M1 and ATmega32M1 uCs.   A couple of details on the optiboot  ports:

  1. The optiboot included has disabled any startup blinking of the LED - in case you happen to have Port 13 assigned to something other than an LED.
  2. Some details on the fuses I selected:
    • Brown-out is set at 2.7v (same as the Arduino UNO), so you should be able to operate at 3.3v (take care of max clock frequency allowed when operating at lower Vcc - hence the 8Mhz versions).
    • The fuses are also set to FORCE  both the A and B outputs of the PSC controllers to a known LOW state upon startup / reset.  (6 output ports:  PSCOUT0, 1 & 2 - both A & B).
    • The clock selected is one of:  16Mhz, or 8Mhz external xtal, or internal 8Mhz osc.

 For the 'core' support libraries, at this time I simply copied over the libs I modified in the v1.0.6 IDE port.  I noted there had been a bit of cleanup with some of the 1.6.0 libs, esp around the hardware serial functions - but it does appear that the existing libs still function w/o problems.  Going forward I will update the core lib functions as errors are found.

Refer to the graph at the end of this post for a mapping of the CPU pins to Arduino PORT names/numbers.  Do make sure to check the Arduino Libs resource tab above for any updates.

Versions enabled include:
  • ATmega32M1 - 16Mhz external xtal
  • ATmega32M1 -   8Mhz external xtal
  • ATmega32M1 -   8Mhz internal osc.
  • ATmega64M1 - 16Mhz external xtal
  • ATmega64M1 -   8Mhz external xtal
  • ATmega64M1 -   8Mhz internal osc.

Enhancements to pinMode() and analgoReag() - Differential inputs.

The ATmegaxxM1 line of CPUs have an extra feature to their analog inputs:  3 sets of adjustable gain differential inputs.  The core libraries have extended to recognize three new 'virtual' ports AD0, AD1, and AD2.  To use one simply uses the analogRead() as normal, but passing one of the virtual port names.  pinMode() has been extend to recognize the three virtual ports - with a slight change; when a differential port is passed to pinMode(), it is always assumed the mode will be INPUT - and the 2nd parameter then becomes the gain factor to be used.  Gain factors may be one of these:  GAIN5, GAIN10, GAIN20, GAIN40.   Here is a sample sketch showing their use:

   void setup() {
     pinMode(AD1, GAIN10);              // Differential input channel #1

                                        // With gain of 10x

   void loop() {
     int i;
     i = analogRead(AD1);            // Read differential channel#1
     Serial.println(i);              // Print its value out
     delay(1000);                    // Delay 1 second between reads

New 'Virtual' ports:
  •   AD0  = Differential input of   D9 - D8
  •   AD1  = Differential input of   A4 - A3
  •   AD2  = Differential input of D10 - A6 
New gain parameters passed as 2nd value in pinMode():
  • GAIN5
  • GAIN10
  • GAIN20
  • GAIN40

A few notes on the 1.6.0 release of the Arduino IDE.  Overall I am very happy to see them include a newer version of the GCC compiler - with its direct support of both the ATmega32M1 and ATmega64M1 uC as well as a better optimizer resulting in perhaps a 5% code size reduction.  It does appear they have also optimized the workflow of the overall tool some - I noted a bit better response / less delays when doing various tasks.

However I am rather disappointing they did not upgrade some of the other tools - e.g. AVRDUDE and the OptiBoot code.  You will still need to manually edit avrdude.cong adding in the ATmega32M1 and ATmega64M1 IDes, but at least now you can have both at the same time.  And for Optiboot - they not only did not upgrade to the latest release, but they totally broke the toolsets needed to recompile optiboot under 1.6.0;  it is a mess, with the only option to use a down rev 1.0.x release for the toolset and add in the latest source of optiboot source.

This is what I did for the boot files needed in this porting.

A final note:  I have only TESTED this port using the ATmega64M1-16Mhz xtl, and 8Mhz Osc options; as that is the boards / CPUs I have at had.  As folks use this if you find any issues with the porting I did, please let me know.

Click for larger view.
(Be sure to retrieve latest version from Arduino Libs resource tab above.)

Thursday, February 26, 2015

Time to checkout the Magic Smoke!

I have finished assembling a solar MPPT controller - here are a couple photos:

I really should not have the camera THAT close.
Those Caps look like towers!
Have also been working to clean up the Arduino IDE and the port of the ATmega64M1 CPU.  I think I have most things fixed and will post corrections as I continue the debugging effort.  A bit on that: the porting is to the IDE version 1.0.5 / 1.0.6.   Arduino just released their 'updated' IDE v 1.6.0, and it will be much better - mostly because it uses an updated version of AVRDUDE and the GCC compiler - providing native support for the ATmegaxxM1 series of CPUs.   However, there has been some large changes in the support files - specifically around the hardware serial port, and it will take me some time to work though that all.  So for now, I am continuing my efforts under the 1.0.x line of the IDE.

Just last night I moved to start some live testing using the Solar Panels on Viking Star.  It is perhaps a good time to do this as the weather has changed, and our overcast winter sky's limit the panels output.  So far results tell me there is still a bit of work to do.  Am not happy with the +12v boost power source, and have worked though a fuse or two already...

But will carry on, and see what all I can get working.