I have a few solar panels on my roof here at the building where I reside in Chicago. These are wired to the basement where they run through a couple of old Trace C-40 charge controllers. Originally I had a small 48 hour battery bank, but that gave out quite a few years back now. In place of the batteries, I have a buffer made out of super capacitors. Those are currently arranged in a series parallel configuration at 1931.84 Farads which I run between 60 and 32 volts as the latter is the lowest cutoff for the old trace 4048 inverter I have here. There are 691 Watt hours of energy usable between those voltage points. I have not always gotten the best use of the power I generate as the panels can charge this up relatively quickly, 15 minutes or so if it is sunny out. I have a relay or two in the trace that I could use for load management, but I would still have to hook them up to control a more powerful relay. What I decided to do instead is to build an external load management system using a micro-controller and some solid state relays to manage the loads.
I don't have huge experience with micro-controllers, but the Arduino's are very simple to use and control by comparison. I ordered up a few to play with. For the project, I went with an Arduino Nano clone which I purchased off of Ebay for about $2.50 U.S. shipped to my door. It came in a static wrapper. The pins were included but not attached, so I soldered them in place.
Downloading the Arduino software is free and relatively straight forward. The only issue I had was that I had to download and install the drivers for the serial interface chip used on the clone as it was a CH340 which was a substitution from the genuine Arduino design. Once I got that sorted out, programming the Arduino to do simple tasks like turn on and off an LED was relatively simple thanks to the excellent documentation from the folks at Arduino and an excellent set of tutorials on Youtube by a fellow named Jeremy Blum. I found that I could control solid state relays right from the output pins which was perfect for my goal. Below are a series of problems I had to overcome to get a usable device
Getting a useable voltage into the Arduino from the capacitor bank:
My system goes up to 60V. so I needed a buck converter that could efficiently drop that to a voltage the Arduino could use. I found a buck converter based on an LM2596 chip advertised as good to 60V. What I found at the cost of a 16 by 2 LCD display was that it actually was not, but more on that later, I did wind up using one with a zener to drop the voltage so the max is about 48V into the converter. Not elegant, and costs some efficiency, but since the device only draws between 10 and 20 mA I guess it is acceptable.
Measuring the capacitor bank voltage:
In the first iteration of the device, I set up a voltage divider on one of the inputs using a 100K ohm resister off the high voltage and a 8.2K ohm resistor for the bottom. This keeps the voltage at the mid point in a range measurable by the Arduino, roughly 7.58 percent of the voltage. Now, in practice I have issues with this as it seems that a slight fluctuation in the supply voltage throws the voltage off. Since the relation between the measured and the actual voltage is linear, I added a couple of parameters when calculating the actual voltage from the voltage divider one to adjust the y intercept, and one the slope so that I could have a reasonable measurement. These were hard coded in the program, but I may switch them to a couple of potentiometers so that I can adjust it in the installation without connecting a computer if I don't find a better solution. I think the voltage measurement is a weak point that I still need to improve.
Ok, so on the programming end I set up variables for the measured voltage and the on and off voltages of the relays. I also set up variables for the output pins for the relays. I ran an outer for loop that calculates the voltage and compares it against the voltage settings for the relays and turns their respective input and output pins on and off accordingly. I set up a 16 by 2 LCD display to display the voltage on the top line and cycle through the voltages on the bottom line.
This worked, but in order to make any adjustments I had to change the voltages coded in the software and reprogram the chip. Thinking that would be inconvenient, I first added 4 analog inputs so that I could adjust the voltages that the relays turned on and set the voltage they turned off to a couple volts below that. I wasn't really happy with the limited flexibility in the relay settings and hysteresis that this allowed for, so I changed it again. This time I added three buttons. Running low on digital pins, I used three analog pins for their inputs. I ran switches through pull up and pull down resistors so that the switch value would go to high when depressed and low when not. I put if statements to check the buttons. I had the first button press turn on the LED for the LCD display, and set it to turn off after a time so as to not waste that power. The three buttons I called select, minus, and plus. I set it up so that if the select button is pressed shortly after the display LED is turned on it goes to a setup menu which allows the voltage at which each of four relays turn on and off to be set. If there is no activity this scrolls back to normal operation displaying the voltage and the cycling through the settings for each relay.
More to follow. . . .