The "ultimate" chp controller!

Started by Fordguy64, November 18, 2016, 06:08:54 AM

Previous topic - Next topic

Fordguy64

Ok well I haven't designed it yet and I'm not really all that great with programming. But I just wanted to start a thread to get some ideas on what we would like in a controller. Now I'm not talking about controlling an alternator or anything like that I'm talking about putting some logic behind a complete chp system. Things like the generator or in my case it will be generators. I have a larger one capable of 7.5kw and a small one good for about 3kw. I have solar panels and a fairly large battery bank of 24v at 840 amphr. Also I plan to build a waste oil burner to heat water.

So this is the part I want input on. The "logic" part. M

Recently I've found out that you can use an arduino or a raspberry pi to check the weather. More importantly it can tell the temperature and if it will be cloudy or rainy or sunny.

With this in mind we could have it look at the battery state of charge and the temperature of the water storage tank. With that information we can take into account when the sun will come up and approx how much sun we will get.

If it will be sunny soon and the batteries are "low" we can wait a little while and see if the solar panels start charging the batteries. If they don't after x amount of time we fire up the gen.

Or if we know it's going to be cloudy we just fire up the gen.

Also if the batteries are full but the storage tank is cold we can fire up the boiler to make some heat.

In theory we can maximize our efficiency by not running something when the solar will be able to take care of it.

Hopefully my rambalings make some sense. If anyone has other ideas or things to control please add it or if you have a better way to improve the logic have at it.

Just want to get the ideas flowing and see what other stuff I'm missing.

Rob  

Edit.. Could even develop a btu needed chart for your home so the control could know how long the water tank could keep your house warm at the given outside temp.

veggie


If you are using an Arduino there are many ways that you could set up a control system.
One simple method that comes to mind is by using A] A light intensity sensor to determine sun intensity (cloudy or sunny) or night-time, and B] a voltage divider shield that converts battery voltage into 0 - 5 VDC to be read by the arduino.

With these two sensors you could monitor battery voltage and cloudiness.

eg:
If BatteryVoltage < 12.3 AND LightIntensity < x, THEN StartGenerator

Just some initial thoughts,
veggie

Fordguy64

Yes that is one way to do it. But I guess my thought was to kind of be able to predict what was going to be needed by checking the weather. But then again I wonder if that would really make a huge difference.

Although something I've noticed with my best thermostate that I really hate. When it's  8:58 and it calls for heat but I have a temp change set at 9 it will kick the furnace on and then kick it right back off at 9.. Sooooo anoying.. That is the kinds of thinks I was trying to avoid with this logic and checkin the weather.

But I even had another idea on something to add into the logic part. Peak energy usage in the house ie cooking dinner in the afternoon or breakfast in the am.

AdeV

Hi Fordguy,

Well, this is the sort of project that's right up my street, so to speak... I've been programming computers far longer than I've been messing around with CHP ideas & old diesel engines...

Anyway - what you're talking about would probably be classed as Artificial Intelligence, rather than "logic" (logic is just If A and/or B then D, and variants along those lines). An AI system would, as you say, look at predictions & make its own predictions, then apply them. So, in theory, it could see that the time is "nearly" 9am, that you've got a lower heat set for 9am, and therefore don't fire up the boiler. Or there's X hours of sunshine expected tomorrow, so don't bother running the genny.

Given that a system like that isn't for the faint of heart (even I'd be outside my comfort zone writing something like that, and I've been writing software for over 20 years), I'd also suggest steering clear of the Arduino as your "intelligent controller". The Arduino is great for monitoring sensors, and stuff like that; but it's not really got the memory or the CPU horsepower* to run a decent AI system. Keeping with the "maker" philosophy, and the KISS principle, I'd look at using a Raspberry Pi board as your central controller, with subsidiary Arduino(s) for various monitoring tasks. They can all communicate with each other using I2C (inter-integrated circuit, a fast and electrically easy way of communicating between different chips & boards, provided they're close together).

The beauty of using an AI approach is it can be a "learning" system; in theory, if it makes a wrong decision you can override it, and it will adapt over time. Mind you... now I'm really out of my depth, that level of AI is pretty specialist...


Aaanyway, the main thrust of the point I wanted to make is: 1) Use a Raspberry Pi (or some other regular computer, a laptop maybe) as your core controller; it's a LOT easier to connect an RPi to the internet, for example, than an Arduino. Use the Pi to monitor and react to weather forecasts. The Pi knows what "time" (esp. daylight vs standard) is, and as long as it's tweaked periodically, will stay plenty accurate enough for our purposes. It's also capable of driving a regular keyboard, mouse & screen, so there's your interface sorted right there. Even better it's aware of regional differences, so the same software would work in the USA (degrees F, miles, yards etc.), in England (degrees C, miles, yards) and Canada (degrees C, kilometers, meters). 2) Use the Arduino to interface with sensors (especially timing-critical stuff), and pass the results back to the RPi on demand. Arduino is GREAT at reading sensors, and controlling motors/lights/bells/etc. Much better than the RPi. And the whole thing can be stuck together with just a few wires and a bit of logic.


* That said, it's amazing what can be squeezed into 1k of code. Some of the things people used to make Sinclair ZX80s do (1KB RAM, 4KB ROM, 3.5MHz CPU) do are quite amazing. Today, if you google "obfuscated C challenge" you'll see people programming quite amazing stuff into a maximum of around 2K of source code (additional part of the challenge: Format the code into a nice ASCII art picture).
Cheers!
Ade.
--------------
Lister CS 6/1 with ST5
Lister JP4 looking for a purpose...
Looking for a Changfa in my life...

BruceM

Hi Fordguy,
Your proposed project sounds like an interesting one.

I agree with Ade; if you want to add weather forecast internet access to your CHP controller a Raspberry PI is certainly a very good choice of platform. And assuming that you don't care about power consumption, there is no penalty for excess computer capacity, especially with the PI being so damned cheap.

That said, I just couldn't resist suggesting that as Ade suggests, a true AI system would be a serious bit of software,  even for a professional.  I'd also point out that the 24/7 power use of the PI MAY be an an issue if you are off grid with a more modest system, compared to a micropower 8 bit processor.

I use a PIC 18F part for my custom 120VDC battery bank controller (which also does generator charger control) and the entire board draws about 7 ma of 5V, 24/7.   The processor uses 2 ma of that. It looks at state and status and input/output from the remote serial terminals once a second.  A bare PI board ranges between 80 and 240ma depending on the model. By the time you add your interface hardware and a display, you might double that if you aren't very careful, as most commercial add on boards/interfaces won't be worrying about power consumption.

If you were to implement a simple system first with an Arduino, that might be a good way to do 90% of your wish list with about 10% of the complexity and effort. You could also design in a simple serial or perhaps even a discrete  interface to the PI or your primary home computer for weather forecast based control.

For project risk management, I would first look at all your interface and sensors carefully, including the interface for the battery state of charge data and how to access it.  With that, date/time via a clock chip shield, and sun intensity measurement via photodetector with diffuser, plus water temp and your other sensors, I think you'd be in pretty good shape.

This is all just stuff to think about, while trying to be realistic about your own skills and needs. Software engineering is unique in all engineering in that it is pure intellect and memory; a highly skilled professional can easily outperform the combined output of 10 mediocre programmers. Since my bout with encephalitis and subsequent MS, software is now near impossible for me and I have to keep things very, very simple. 

Best Wishes,
Bruce

Jens

I am currently knee deep into pi and it's yummy :)
I concur that this is probably the best choice in a lot of instances for more involved controllers and there is an awful lot of code out there that you can use as examples or combine to make a franken pi. I agree that power issues are important to be aware of before you get yourself too much engrossed.
With the pi3 having a gig of ram, 4 usb ports, ethernet, wifi and bluetooth, it is ideal for integration and interaction. The learning curve can be a bit of a Mount Everest experience though. I am currently stuck trying to understand (from example code) how object oriented programming works in order to put a simple temperature gauge up on the screen.

Good luck !

AdeV

Quote from: Jens on November 28, 2016, 02:51:48 PM
I am currently knee deep into pi and it's yummy :)
I concur that this is probably the best choice in a lot of instances for more involved controllers and there is an awful lot of code out there that you can use as examples or combine to make a franken pi. I agree that power issues are important to be aware of before you get yourself too much engrossed.
With the pi3 having a gig of ram, 4 usb ports, ethernet, wifi and bluetooth, it is ideal for integration and interaction. The learning curve can be a bit of a Mount Everest experience though. I am currently stuck trying to understand (from example code) how object oriented programming works in order to put a simple temperature gauge up on the screen.

Good luck !

Hi Jens, long time no see! (that may be because I haven't been here for ages.... not sure...)

What language are you working in? OO is one of those funny things, you'll suddenly have a "Eureka!" moment, and will wonder how you ever didn't get it in the first place... At least, that's what happened with me, about a month into working with Visual Basic 4 (the first "proper" OO version of VB).

These days I work with VB.Net; which has the rather nice attribute that programs written in .Net will, mostly, cheerfully run on Linux as well as Windows... so finally I get to cross-compile my code :D I never did get the hang of "C++", or "C" for that matter, but I can just about manage your basic Arduino stuff. It sure was funny going back to procedural code, after what feels like a lifetime of OO programming...

Cheers!
Ade.
Cheers!
Ade.
--------------
Lister CS 6/1 with ST5
Lister JP4 looking for a purpose...
Looking for a Changfa in my life...

Fordguy64

Thanks for the input guys. Well I agree with the pi being the better option for a controller. I had planned on it being a "headless" system. IE not monitor hooked up and just use a android based tablet for control/monitoring. That should lower power consumption. I also like the idea of having one main controller and then having arduinos controlling the individual sensing of the different parts of the system.

As far as battery monitoring al (he made some nice arduino based small engine controllers on the site) has been working on a can system that will allow most of his creations to talk to each other. I also have some of his engine controllers on hand but aren't assembled or in use yet.

I was talking to a guy at work who is an electrical engineer and also loves playing with arduinos and pi's about my controller idea and he didn't seem to think it would be to difficult to pull off. He mentioned you can actually pull weather data from the web in structured info that can easily be used in a program. I had no idea you could do that! So that makes the prediction of the weather much easier to handle. No need for light sensors or temp sensors.

He seemed like he would be willing to assist in the programming of such a device. Although I'm in the process of trying to get my house ready to sell (finishing up a bathroom remodel) so I just don't have time to mess with it at the moment. I kind of started this thread just to try and get the creative juices flowing. Try to get input on what features would be nice to have? What parts of the overall system to monitor and or use for the logic or "ai"

I think with being able to pull the weather forcast from the web and actually have usable info from it will be a huge step in making the project simple, or somewhat simple. Pull the forcast for the next few hours and decided what gen to run or if it's even needed because the solar will take over on the batteries.

So keep up the discussion I'd like to see what you guys would like to have intragrate with this

veggie

#8
+1 for what AdeV said.
I have been programming VB6 and VB for several years also... and the Arduino is a great way help a PC interface with the world.
So in your case you could use a PC to gather web data (weather) and the arduino to gather battery voltage and local light intensity data, ...then formulate your next move.
VB6 and VB.Net can easily communicate with the WEB and the Arduino, and decisions made by the main program (brain) in the PC can be implemented by sending serial commands to the Arduino.
The Arduino can be connected to sensors and relays in your project to activate actions and/or feed data back to the PC for processing, plotting, or logging.

I recently built a system to monitor a hydroponic lettuce growing system which uses the arduino to gather sensor data from float switches, a flow meter, and two temperature probes.
The data is sent back to a VB program in the PC which monitors the system 24/7 and sends me a text message if flow, level, or temperature get outside of set parameters.
If all is ok, it still sends me a message once in a while telling me that things are ok.(that is to confirm that the monitoring system is still working).
Next for the project is to control a solenoid valve to top up the nutrient tank when the level gets too low.
More fun than a barrel of monkeys !

Veggie


Alas, I don't want to hijack this thread with programming talk....will start another thread.

Tom Reed

Lots of like minds here. I've programmed VB3, VB4 & VB6 along with VB.net and Arduino too. I mostly specialize in database apps. Got a big Arduino/PC app under discussion.
Ashwamegh 6/1 - ST5 @ just over 4000 hrs
ChangChi NM195
Witte BD Generator

Tom

Fordguy64

So I've started playing with programming Python. I actually kind I like it. Anyway I started writing down possible inputs and outputs for this controller idea.

"Inputs" or rather variables?
1 cloud cover/sun/rain
2 outdoor temp
     Both will be looked at in a few hours into the future to help decide how to continue.
3 what else?

" options to charge and replenish"
1 solar panels
2 prime mover
         Exhaust/coolant heat recovery
         Dc charger
         Ac generator
         Possible engine driven heat pump?
         Air compressor?
3 small generator
         Dc charger
         Exhaust/coolant recovery
4 heat/cool source
         Oil burner
         Pellet burner/wood chip/ biomass
         Outdoor wood boiler
        ?

Then we have things like calculating btuh in a storage tank and the btuh loss of the home or building.
This will also be a variable for what system to run to get things back to charges or full level.

Anything I'm missing?


veggie

#11
Well, that in my opinion would be far to complicated for a first time project.
Far too many variables and permutations. Creates a "ghost in the machine".

Before programming can begin you need to establish the relationship between the various pieces of equipment.
On paper, come up with the logic that will govern the system and eventually become your program.
I suggest breaking your project in to small bite seized pieces that can be brought together later.
For example, first develop your system for monitoring weather.
Once that is working, add components to the program that can react in certain ways depending on your "weather rules".

Sensors....
1] Cloud cover, sun, and rain is generally not one single  variable but two.
Cloud cover and Sun are monitored using a light intensity meter.
Presence of rain is measured using a resistive rain plate like this
http://www.ebay.ca/itm/Raindrop-Rainwater-Module-Rain-Sensor-Module-for-Arduino-Kits-/171371221109?hash=item27e6855075:g:G9cAAOSwxH1UK503

As far as the other stuff goes, you have not really elaborated as to what you would want to do with the DC charger, pellet burner, air compressor etc. They have little to do with a CHP system. Do you want to control them or just monitor them ? If controlling them you will need many rules and conditions to interlink the systems.

Start very small and get used to the programming and the sensors you will be using.

cheers,
Veggie


Fordguy64

http://thecodeinn.blogspot.com/2013/07/tutorial-weather-forecast-in-python.html?m=1

That's an older post but it gives a general idea of how to get weather data from the web using Python. I have yet to try it on my raspberry pi but hopefully sometime in the next week I'll get around to it

Jens

Quote from: AdeV on November 28, 2016, 06:47:20 PM

What language are you working in? OO is one of those funny things, you'll suddenly have a "Eureka!" moment, and will wonder how you ever didn't get it in the first place... At least, that's what happened with me, about a month into working with Visual Basic 4 (the first "proper" OO version of VB).


Python is the poison of my choice at the moment .... but the "Eureka" moment has escaped my grasp for the time being.
I am not spending a lot of time on this at the moment but rather it's a hobby that gets played with when I feel like it. It might take me several months for the lightbulb in my brain to switch on. On the bright side, there are a lot of resources and very little need for writing code from scratch which is a great thing :)
I have a pi connected to my home wifi and access it via remote desktop so it is very easy to bring up the pi window for some play time whenever the mood strikes.

Fordguy64

So I might actually get around to working on this. The house I just bought has a detached garage. It had its own separate electric meter that cost 40$ a month just for that meter.. Needless to say my garage is off grid and running on my 1kw solar array. I currently don't do much in there as we are about to get married. But after that I'll be getting my Kubota generator up and running. I'll be attaching the z482 to a 5kw gen head to feet into my magnum 4424 inverter with built in charger. That should pretty we'll hold me over for a while. Somewhere in that time all be setting it up for chp duty. Eventually I should end up with about 3kw of solar.then I'll add  some large pex and some wire to run from the garage to the house. I'll then have a secured load panel set up in the house that will run off of the solar and gen as much as possible.