Microcontrollers > Microcontrollers/General

Arduino inverter load controller

(1/10) > >>

richhagen:
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. . . .

richhagen:
On the hardware end of it, I got a box with four breakers and split the bus so that I could run the output from the inverter directly to one of the breakers and through solid state relays for the other three.  I intend to use the fourth relay output with a DC relay to heat some water.  I am thinking I can run the really low control current through a water heater thermostat and run DC from my capacitor bank through a heating element to heat the water.  (I figure a 2000 Watt 120V element is about 7.2 Ohms and will draw about 500 Watts at 60V, so with two that should get me about 1000 Watts into the water while its running, which will only be when the voltage is near 60V. ) 



For test purposes I ran each output to a single outlet and rigged a temporary power cord for the box.  I tested this off of my benchtop power supply.  It seemed to work OK.   

I then switched it over to my inverter power out and the capacitor bank for the DC voltage.  I didn't have a DC relay handy, so I put the fourth relay output out to another solid state AC relay.  Once that was done I hooked it all up.  The first day it broke :(  The DC buck converter broke as it turned out.  Fortunately the Arduino survived, but the LCD was killed.  Probably the chip set on it.  Fortunately I had a spare for both the buck converter and the LCD and was able to get it back up and running.  It had survived without issue up to 51.6 V., but at 60 it did not.  I ordered up a 5 Watt 12V Zener to drop the supply voltage to the buck converter and have had no issues with the replacement buck converter since.  Once the Zener arrived I ran the power through a test lead to the diode and then through another test lead to the power for the buck converter.  The voltage divider was attached to the capacitor bank voltage directly.  Of course when I first rigged this up I accidentally dropped the zener with the leads attached and it made contact with one of the capacitor bank bus bars.  I don't know what became of the diode portion, but there was a flash and a bang and all that was left were the leads one of which was welded to a test lead.  Fortunately again I had another zener, so I 'carefully' rigged it up and the setup worked at that point.



At present, I have it temporarily configured with a 9.5W LED bulb hooked to the outlet always on when the inverter is on, I don't have anything hooked to the first relay, I have a cord running to lights in my plant room on the second relay, and the third relay is hooked to a 1500W space heater.  The fourth relay I don't have anything connected to, it is just sitting outside of the breaker box for testing purposes.  It is working well now with the exception of the voltage accuracy. 













I figure I can mount the circuit onto a 2 inch by 4 inch pcb and designed a box to house the board along with the LCD and three buttons.  I put two half inch holes for conduit connections on the box. 













Of course my 3D printer ran into a problem about half way through the first part, so the cover will have to wait for now. 












At any rate this is currently where this project is at.  I need to make a box for the pcb and then to mount it and hard wire it in a more stable permanent location. 

DamonHD:
Very good!

You have more usable energy storage in your supercaps than I have in my (aux) LiFePO4 battery, I think!

(I'm hoping to soon play with another ~5kWh of storage, but heat this time, in PCMs.  My electric storage is ~2kWh, off-grid.)

Rgds

Damon

OperaHouse:
I think we could see some interesting stuff out of this. Ain't it the truth, if you can just
get it to blink the rest is easy.  I should have a couple of those boards arriving in a few
days.  I have a number of the non UART boards, but I left the FTDI programmer at the camp and
decided to get them with the built in USB since the price has dropped.  If you have a spare one
I have an idea that I've wanted to try with someone that has a C-45.  It should fit right into
your situation.

The 2596 regulators are almost always clones.  I love them but use them only conservatively.  You
have enough voltage to use standard electronic wall warts.  My buss is about 50V and I power
everything with them. Sometimes I open them up to eliminate some of the diodes and about 40 ohms
of resistance used as filters on the power line side.  For light loads I use them as they are.
Nice thing is that they fail safe.  Being isolated these are very nice for high side drivers,
just add a FET and an opto isolator.  Opto isolators are slow, but I have no trouble driving a
FET at 15A 490Hz PWM rates.  Just inhibit really narrow pulses at each end of the PWM.

There is a voltage reading issue to be aware of.  When the USB is plugged in, the reference
voltage the A/D may change since it will operate on whichever 5V is higher.  To avoid this I
slice a USB cable open and cut the 5V line and insert some back to back diodes.  A capacitor
should be in parallel with the A/D input. This will provide noise protection and filtering. 
It also reduces the input impedance  for a more stable reading with higher resistance dividers.
When grabbing data off the USB line using TOOLS you may have noticed that the micro resets when
the USB is plugged in.  This will erase any data stored.  Connecting a 20-100uF on the reset
line will prevent that. Floating point math should be avoided as it greatly slows down processing
speed.

richhagen:
I had noticed the different voltage readings when a USB cable was connected and attributed it to a difference in supply voltage.  In my case, I'm not leaving it connected, although I still haven't commented out the serial port data I was sending when I was setting it up. I will have to look at the wall wart idea, I am assuming these are switching power supplies.  Most of the ones I have seen are rated for a minimum 100VAC input, although I presume they do rectify it and convert it and similar to the converters in some of my LED bulbs can handle much lower.  My system does drop all the way to 32V, and a bit lower than that toward the end of a cold winter night due to the remaining dc draws after all the usable energy has been drained by my inverter.  Rich

Navigation

[0] Message Index

[#] Next page

Go to full version