Today's thrilling episode is the cheapskate's guide to load automation...
Now that it's getting sunnier, I've started using the water heater again. The problem is that it uses a lot of power and unless it's a perfectly clear day you get the odd cloud or the weather changes and suddenly its eating up the battery instead of soaking up spare power from the array. I can run upstairs and turn the thing off and on but that means babysitting a water heater... Not clever.
So... Here's my old Toshiba T4900CT laptop - £5 from a car boot sale. £25 for new battery. £5 for an ancient Ethernet adaptor that came with two free laptops... I luv car boot sales, me.
This one's a winner as a data logger as it's a P-75 processor that consumes just 11W when snoozing on half speed CPU and the screen and hard disk asleep (coz it's sending the data to a file share upstairs). Windows 98 runs well on a dozing Pentium with 12Mb RAM... Ahh... those were the days.
The machine is plugged into the SunSaver MPPT charge controller by it's serial interface (only old laptops have proper RS232 ports) and the Ethernet card is plugged into the TriStar MPPT charge controller. The MSView software just reads off the system parameters and pipes them to a single CSV data file on the file server upstairs. Up until now it's managed to make some pretty graphs. Time for some real work.
Velleman make a bunch of kits and this is the K8055 USB I/O card. You can get one pre-assembled but it's £10 cheaper to get the kit and make it yourself. So I did. It also means I could leave out some bits I didn't need and they might come in handy for some other project.

The finished article is a useful bit of kit and a bargain at £30. It has 4 digital inputs (for switches), 2 A/D converters for 0-5V sensors, 2 D/A converters with either analogue 0-5V output or 0-100% PWM signal and 8 digital outputs with LEDs (that could be converted to opto-isolators) and screw terminals for connection to the open collector drivers (the bit I'm interested in right now) for relays and so on.
The whole thing is powered by the USB port itself and works with the pre-programmed PIC controller on board and a supplied DLL for Windows to talk to it. Velleman provide a bunch of demo code and a test program so you can play with it almost right away. You can even gang four of these boards together on a USB bus as they have separate address codes that the DLL can talk to.
The plastic box it came in is sturdy and see through and will probably make a half decent case for the finished thing!

To drive a relay you need an external 12V DC power cube (car boot sale) and a mini 7A mains relay (scavenged from a dead UPS I have). The relay fits conveniently inside this two way mains socket

I love it when a plan comes together!

I happened to have an old copy of VB6 sitting around in a cupboard and so some fettling of the demo software source code gave me the interface I needed. I read the Morningstar CSV data file and scan it for new entries (once every few seconds as it is being updated once every 15 seconds by the logger). The new program builds an output CSV file that has the calculated values for the sum of the charger currents and the total generated power. These can then be read by MSView on the server to display real time graphs of the total system output (previously I had to doctor the CSV file with Excel to get the graphs I showed earlier).
This program is only really interested in the battery and system state though. Some rules decide when there might be available surplus power. It does this by looking for when the battery is getting full at over 27V and with the array power being low (because it has finished absorbing and / or there are no other big loads on - e.g. the kettle). The program tells the relay to turn on and the water heater starts. This loads the system by 650W and if there's surplus array power the battery voltage will hold up as it continues to charge or just float. The array can produce about 1100W on a good day so there should be juice to spare. If not, the battery volts will fall and then the second parameter watches for this (now ignoring the power output). If there's not enough solar juice, the battery will fall below float and the relay is turned off until the battery has recovered (back to above the voltage threshold and consuming less than the set power).
I'm still working on it so some things don't do anything yet. The output check boxes will turn on/off other outputs but the automation works just on output 1. The inputs are ignored (for now) but could be triggered from any switches (the Smartgauge has a relay output that can be triggered by a low SoC directly). I've put some safeties on it too - ending the program turns off the outputs first. A heartbeat senses if the logger has stopped sending data and shuts off the outputs. Some range validation ensures that you can't put unreasonable thresholds in the variable boxes.

Here's what it did this afternoon as it got progressively more cloudy. You can see there's enough power to charge the battery quite quickly but not enough to run the water heater so it cycles on and off (very slow PWM). So I can now leave the thing plugged in all day and the load manager will give priority to charging the battery but whenever there's enough spare power it will progressively dump more and more into the water heater.
You can see where I turned on the 900W kettle for a quick cuppa and this drained the battery a bit. The water heater shut off (as the volts sagged below the cut-off level) and it stayed off as the volts came up and the power drawn by the battery subsided. This last bit is important as just looking at the voltage doesn't work because the voltage comes up quickly. If you watch the power curve as well, you can tell when the battery has stopped absorbing power and it's safe to divert power to the heater.

The other outputs aren't used for anything (yet!) but I've got three more of those relays and they'd probably all fit in a typical 4 gang mains adapter

Morningstar wanted over £130 for their relay driver...