Project: Solar/Wind PIC controlled battery array

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
This is a system to keep up to 4 isolated batteries charged from a single solar/wind power generator. It's using aPIC18F8722 Microcontroller from http://www.futurlec.com/PIC18F8722_Controller.shtml as the controller with software written in C18 from Microchip. Most of the parts came from junk from old equipment at work but I need to buy a full array of solar to make it useful.

The plan is to monitor the batteries and have it select the best one to charge and to alert via RS-232 link any abnormal conditions.

Most of the basic hardware/software is in place for testing. Nothing fancy just relays for switching and some A/D inputs for monitoring voltages and current. For now it's just running outdoor lights and music but the plan is to use an inverter for AC power during the summer for cooling a outdoor room.

http://www.flickr.com/photos/nsaspook/sets/72157622934371746/show/
 

bertus

Joined Apr 5, 2008
22,270
Hello,

The Projects Collection (as opposed to The Projects Forum) is for sharing completed projects. I've moved your post into The Projects Forum, where it will draw more responses.

Can you post schematics and code?

Good luck with your project!
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
Hello,

The Projects Collection (as opposed to The Projects Forum) is for sharing completed projects. I've moved your post into The Projects Forum, where it will draw more responses.

Can you post schematics and code?

Good luck with your project!
Tks.

Microcontroller port wiring:
The 5 volt relays control 40amp SPDT relays that switch the charging currents and load testing resistors to the batteries.

Detail relay wiring:
In progress

Source code:
C18/MPLAB, In progress. Need to complete status reports and power profiles.
 

Attachments

Last edited:

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
That looks pretty nice. Out of curiosity why do need to keep the batteries separate? Why not put them in parallel?
I have a mix of AGM, flooded and gell type batteries all needing different charging methods and levels. I have my 2Kw inverter installed and plan install a programmable charge controller along with a switched fan and hood to remove charging gasses.

I'm still in the building stage so it's a little messy.



Controller (still wiring and testing software)



Updated software and basic wiring/block diagrams.
 

Attachments

Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Interesting project.

Appreciate the fact that you used reclaimed materials.

However, are the relays you used the latching type? I'm wondering about their constant current consumption; it would tend to decrease the overall efficiency.

Do you occasionally perform an equalization charge on the lead-acid types?
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
How are you regulating the voltage from the solar panel?
I'm using a external PWM charge controller for most battery charging but there is a bypass mode that can use a load shunt. The current controller came with the solar panel kit but I plan to install a programmable unit connected the PIC to monitor power and usage stats.
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
Interesting project.

Appreciate the fact that you used reclaimed materials.

However, are the relays you used the latching type? I'm wondering about their constant current consumption; it would tend to decrease the overall efficiency.

Do you occasionally perform an equalization charge on the lead-acid types?
That is a design consideration. I've tried to wire the high power SPDT relays so the off position delivers power to the inverter and only one need to be on to charge that cell. The PIC control relays are OMRON G6B-1174P 5vdc types http://www.omron.com/ecb/products/pry/121/g6b_117.html and use 200mw when on. I have a huge supply of these from some long forgotten project at the work junk room, so the price was right. I also have the mounting rails. http://norkom.beta.qt.pl/www_dokumentacja/przekazniki/j098-e1-02_en_g6b-4_datasheet.pdf

I started programming in a equalization charge routine by bypassing the current charge controller but my new charge controller will be able to do that for me with the right commands. http://www.xantrex.com/web/id/72/p/252/pt/25/product.asp
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
Time for a update on this thing. I finally got most of the parts to make it operational and useful for tending the battery arrays. Most of RS-232 datalogging and control functions are done and the real charge controller has been installed and tested. I can now monitor input/output power usage for the PV array and inverter with real-time data for system status.
The PIC ADC converters read voltages and a set of AMPLOC current sensors (50A, 300A) read the input/output currents.
http://amploc.com/AMP--55a.pdf
http://amploc.com/KEY100.pdf.pdf

They run on 5VDC with 2.5VDC outputs at no current so PIC interfacing was easy.

The current problem is interfacing with the XANTREX C40 controllers remote LCD display serial interface connection. It seems to be lowspeed 300 baud RS-422. They provide no help on the wiring or protocol but I have a 422 converter on order to dump the data-stream. With this data sent to the PIC I can then use the C40 charge status to switch cells instead of a timed/voltage method.

Data to laptop. right click to download http://www.flickr.com/video_download.gne?id=4445888465

Data chart from data. http://farm5.static.flickr.com/4039/4446789590_fa64e62053_o.png

More baby pictures. right click to download http://www.flickr.com/video_download.gne?id=4446662934

Current C18 pic18f8722 source code attached.

Rich (BB code):
/*
 * This program controls and monitors solar power battery arrays
 * 
 *  
 * USART2   is the host comm port
 * USART1  charge controller port (NOT YET DONE)
 * Timer0  1 second clock
 * Timer1  background I/O clock
 * PORTA  analog inputs
 * adc0 vbatol    PIC Controller supply voltage to 5VDC regulator
 * adc1 solar    Charging voltage at battery from CC
 * adc2 currentin   50A AMPLOC sensor input from PV array
 * adc3 rawp1/inputpower Voltage from PV array
 * adc4 rawp2/primarypower Voltage a primary inverter battery
 * PORTF  analog inputs
 * adc5 current    300A AMPLOC sensor battery output to inverter
 * PORTD  switch input
 * PORTE  battery/charge relays
 * PORTJ  load/input relays
 * PORTB  external control i/o
 * PORTH0  run flasher led onboard.
 * 2x16 LCD status panel and led status lights.
 * 
 * xxxxxxx@xxxxxx.com Copyright 2010
 * Fairview, Oregon
 * 
 * 
 * This application is designed for use with the
 * ET-BASE PIC8722 board and  LCD device.
 *  
 * RS-232 host commands 9600baud 8n1
 * A  send controller/battery status
 * B  select battery for modify commands, used with S M L
 * C  (NOT DONE YET)
 * D V M L Calibrate ADC voltages, example DVMZ would adjust adc0 up 1 tick, DDDVLLZ would adjust adc2 down two ticks
 *   THIS FUNCTION USES THE EEPROM WRITE DURING INTERRUPT (TOO MANY FAST KEYPRESSES WITH CAUSE A LOCKUP)
 * F  Force current (none critical) charge routine to exit
 * K  lockup controller causing WDT timer to reboot
 * S M L modify selected battery type, example: ZBBMZ would set battery 2 to M type.
 * Z  reset command parser
 * ?  controller attention needed/sent to host to request action (usually a status)
 * $  fuse blown error. (NOT DONE YET)
 * 
 * 1.  Creating large data objects
 * 2.  Reading from and writing to the USART. 
 * 3.  Interrupt handling (#pragma interrupt, interrupt vectors, and
 *     interrupt service routines)
 * 4.  System header files
 * 5.  Processor-specific header files
 * 6.  #pragma sectiontype
 * 7.  Inline assembly
 */
 
Last edited:

russpatterson

Joined Feb 1, 2010
353
Hi There,

Cool project. Thanks for posting all your work. I couldn't get the flickr links to work (right or left click). I'll pass on some warnings a guy gave me last weekend who's done this stuff before. Batteries can vent hydrogen so keeping them right next to all those high voltage, alligator clipped, electronics can be bad for your garage.

I'm building a battery (battery's only) box vented to the outdoors as my next project.

Is the goal with the PIC to log the data? Are you doing any control with it?

Why is the current so erratic over this 30 second period? http://farm5.static.flickr.com/4039/4446789590_fa64e62053_o.png
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
Hi There,

Cool project. Thanks for posting all your work. I couldn't get the flickr links to work (right or left click). I'll pass on some warnings a guy gave me last weekend who's done this stuff before. Batteries can vent hydrogen so keeping them right next to all those high voltage, alligator clipped, electronics can be bad for your garage.

I'm building a battery (battery's only) box vented to the outdoors as my next project.

Is the goal with the PIC to log the data? Are you doing any control with it?

Why is the current so erratic over this 30 second period? http://farm5.static.flickr.com/4039/4446789590_fa64e62053_o.png
It's pretty well vented next to the very leaky garage door. I have a vent pipe to purge the gas outside in the works. I have a old MST gas sensor from work that will monitor the H2 concentration. In a week all the jumpers will be gone and conduit junction boxes will have all the connections enclosed. The PIC will log the data, monitor battery condition and provide a "time to run/history" data via the serial port to a linux system that runs my current home automation system. The comm protocol is in a primitive state now for debugging but will be fully capable when the front-end software is mainly done.

Each X marker is 30 seconds, so that trace is about 30 mins of data. I need to filter the power to the AMP sensors and shield the signal lines to reduce bit jitter.

I found the easy way to get data from the C40 controller. Just connect a sense wire to the C40 status led and monitor that on a input on the PIC. Now I know when the C40 is in BULK, ABSORPTION or FLOAT and has fully charged the battery so I can do battery run time calculations.
 
Last edited:

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086


(after controller reboot, not synced with real battery state yet)
Battery 1&2:
Voltage, run-time (hr:min), state of charge (%), Ah used

Charge monitor:
Battery under charge. Max time on charger if C40 didn't go to float mode (monitor LED).

Pv voltage, Battery voltage, charge amps
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
After working in rain for 2 months, it's finally above 80 here. Took some photos of the system in operation powering the sun-room outdoors. Flickr slideshow. http://www.flickr.com/photos/nsaspook/sets/72157622934371746/show/

Dual inverter power monitor screen. Battery 1 running inverter in float charge mode.
Line 2: PV input voltage CC output voltage, charge current.
Lines 3&4: battery 1/2 voltage,run time at current usage, soc, Ah used.


Analog meters for PV input.


Solar arrays: Unistrut and old Sat dish mount.


Old TV with dtv converter box, cheapo am/fm cd player and cooling fan.


C18 source code: Still under development but mostly working.
http://mysite.ncnetwork.net/res02dad/sitebuildercontent/sitebuilderfiles/swm8722.zip
 

coldpenguin

Joined Apr 18, 2010
165
Impressive,
How many AH in total do your batteries store, and what current can they provide?

It is difficult to judge the scale of your PV cells, how large are they?
I have made some which are theoretical 300W, this comes to be aound 8x4 foot in size! But the UK sun seems to be a tad weaker than yours, not sure I'll ever get a TV working from them!
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
Impressive,
How many AH in total do your batteries store, and what current can they provide?

It is difficult to judge the scale of your PV cells, how large are they?
I have made some which are theoretical 300W, this comes to be aound 8x4 foot in size! But the UK sun seems to be a tad weaker than yours, not sure I'll ever get a TV working from them!
I have 220Ah of battery storage with about 230W of solar input total. My pic controller derates the Ah by half for the run-time calculations to keep the battery healthy. I can run my 2kW inverter at full power for a short time if needed but normal load is about 200w. During the sunny days the solar powers everything outdoors.

The two panels on the pole are Sharp 80W models. I have the smaller units mounted in a shed roof.

http://www.wholesalesolar.com/pdf.folder/module%20pdf%20folder/NE-80EJEA.pdf
 
Last edited:

coldpenguin

Joined Apr 18, 2010
165
How did you come up with the amount of battery storage that you need? Did you just happen to have them lying around, or did you determine it using a factor of how long and how much current you thought your devices would need?
 

Thread Starter

nsaspook

Joined Aug 27, 2009
13,086
How did you come up with the amount of battery storage that you need? Did you just happen to have them lying around, or did you determine it using a factor of how long and how much current you thought your devices would need?
The general rule is to size your battery so the panels can charge it at 5 to 10% of the battery Ah rating. My basic requirement was to power the outdoors equipment completely on solar during the day and to have at least 4 hours battery reserve for nights.
 
Top