Project: Solar/Wind PIC controlled battery array

Discussion in 'The Projects Forum' started by nsaspook, Jan 15, 2010.

  1. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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/
     
  2. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,347
    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!
     
  3. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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.
     
    Last edited: Feb 12, 2011
  4. russpatterson

    Member

    Feb 1, 2010
    351
    16
    That looks pretty nice. Out of curiosity why do need to keep the batteries separate? Why not put them in parallel?
     
  5. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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.

    [​IMG]

    Controller (still wiring and testing software)

    [​IMG]

    Updated software and basic wiring/block diagrams.
     
    Last edited: Mar 1, 2010
  6. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    How are you regulating the voltage from the solar panel?
     
  7. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    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?
     
  8. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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.
     
  9. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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
     
  10. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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.

    Code ( (Unknown Language)):
    1.  
    2. /*
    3.  * This program controls and monitors solar power battery arrays
    4.  *
    5.  *  
    6.  * USART2   is the host comm port
    7.  * USART1  charge controller port (NOT YET DONE)
    8.  * Timer0  1 second clock
    9.  * Timer1  background I/O clock
    10.  * PORTA  analog inputs
    11.  * adc0 vbatol    PIC Controller supply voltage to 5VDC regulator
    12.  * adc1 solar    Charging voltage at battery from CC
    13.  * adc2 currentin   50A AMPLOC sensor input from PV array
    14.  * adc3 rawp1/inputpower Voltage from PV array
    15.  * adc4 rawp2/primarypower Voltage a primary inverter battery
    16.  * PORTF  analog inputs
    17.  * adc5 current    300A AMPLOC sensor battery output to inverter
    18.  * PORTD  switch input
    19.  * PORTE  battery/charge relays
    20.  * PORTJ  load/input relays
    21.  * PORTB  external control i/o
    22.  * PORTH0  run flasher led onboard.
    23.  * 2x16 LCD status panel and led status lights.
    24.  *
    25.  * [EMAIL="xxxxxxx@xxxxxx.com"]xxxxxxx@xxxxxx.com[/EMAIL] Copyright 2010
    26.  * Fairview, Oregon
    27.  *
    28.  *
    29.  * This application is designed for use with the
    30.  * ET-BASE PIC8722 board and  LCD device.
    31.  *  
    32.  * RS-232 host commands 9600baud 8n1
    33.  * A  send controller/battery status
    34.  * B  select battery for modify commands, used with S M L
    35.  * C  (NOT DONE YET)
    36.  * D V M L Calibrate ADC voltages, example DVMZ would adjust adc0 up 1 tick, DDDVLLZ would adjust adc2 down two ticks
    37.  *   THIS FUNCTION USES THE EEPROM WRITE DURING INTERRUPT (TOO MANY FAST KEYPRESSES WITH CAUSE A LOCKUP)
    38.  * F  Force current (none critical) charge routine to exit
    39.  * K  lockup controller causing WDT timer to reboot
    40.  * S M L modify selected battery type, example: ZBBMZ would set battery 2 to M type.
    41.  * Z  reset command parser
    42.  * ?  controller attention needed/sent to host to request action (usually a status)
    43.  * $  fuse blown error. (NOT DONE YET)
    44.  *
    45.  * 1.  Creating large data objects
    46.  * 2.  Reading from and writing to the USART.
    47.  * 3.  Interrupt handling (#pragma interrupt, interrupt vectors, and
    48.  *     interrupt service routines)
    49.  * 4.  System header files
    50.  * 5.  Processor-specific header files
    51.  * 6.  #pragma sectiontype
    52.  * 7.  Inline assembly
    53.  */
    54.  
     
    Last edited: Feb 12, 2011
  11. russpatterson

    Member

    Feb 1, 2010
    351
    16
    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
     
  12. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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: Mar 26, 2010
  13. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
  14. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    [​IMG]

    (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
     
  15. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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.
    [​IMG]

    Analog meters for PV input.
    [​IMG]

    Solar arrays: Unistrut and old Sat dish mount.
    [​IMG]

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

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

    Active Member

    Apr 18, 2010
    165
    9
    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!
     
  17. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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: Jun 13, 2010
  18. coldpenguin

    Active Member

    Apr 18, 2010
    165
    9
    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?
     
  19. wannaBinventor

    Member

    Apr 8, 2010
    179
    4
    I have nothing to add, I just wanted to compliment you on the project. Very impressive.
     
  20. nsaspook

    Thread Starter AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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.
     
Loading...