Monday, July 25, 2011

So, a pack rat got into my swimming pool wiring.  I think it was a pack rat because stuff was missing; usually when a normal rat, mouse or squirrel gets to wiring it's all still there, just torn apart.  This time large pieces were missing.  Took all morning to put it back together and then the pool controller got the famous Goldline burned solder connection problem.  See http://www.nocellpower.com/ for a complete description of the problem and solution.  Goldline, and now Hayward since they bought the company, have known about this problem literally for years and nothing has been done about it.  The darn pool manufacturers sell these things and tell us how good they are.  Sigh....

Anyway, I got it all fixed and then cleaned the salt generator and pool and ran the motor on high speed to test everything out.  Worked fine, but I forgot to turn the motor back off before the peak period.  Timers usually do this for me, but I overrode them to test the pool system.  Well, I now have a 2.4 peak demand number for the 45 minutes that I ran the pool.  That'll cost me a little bit, but since I have family coming this month, I sort of expected to have a higher bill.

I'm going to have to think about this a bit.  There must be a solution to forgetting something like this, it just isn't coming to mind right now.  I don't want to constantly turn stuff off to be sure it stays off.  Maybe an alarm that sounds when the power gets too high or something.  I'm not quite ready to start on the load shedding project I want to do eventually.

Tuesday, June 28, 2011

Bragging about the house controller ... again.

I'm actually pretty impressed with the capabilities of these little computers (as if you couldn't tell).  I added a short video of the House Controller to the tab above.  It isn't real impressive since it only does the mundane stuff like help me save around $100 bucks a month on my power bill, but it is fun and still growing.

Monday, June 20, 2011

House Controller

Finally started documenting the House Controller.  I've mentioned it several times, but the darn thing is a ton of code and has been the focus of most of my efforts for a few weeks now.  It uses XBee to connect into the network I constructed and has an ethernet board so that I can tell it what to do as well as get information from it.  It also uses the ethernet board to control my two web enabled thermostats.  I control the pool and the thermostats as well as sample the data from my various devices.  I can see the inside temperature, outside temperature, power usage and such from my laptop in a chair anywhere in the world.  I use the Arduino TimeAlarm library like a task controller to schedule various events like turning off the A/C at certain times.  I also turn the pool pump off in the evening just in case someone (me most likely) left it on.

It has an LCD display that shows various items I like to watch in sequence and a ton of colored LEDs that show the various conversations going on around the house.  Naturally, it isn't done yet, not by a long shot.  Heck, I've only used about a fifth of the memory on it and I have CPU cycles to spare.  I will be expanding it to control the X10 devices I have, and as I add new devices, I'll put in code to handle them.

It's on the House Controller tab above and I'll have pictures so you can see it soon.  If you want to sample the web output, click here.

Monday, June 6, 2011

Stupid Arduino 2560 Board

The Arduino mega2560 board is cool.  It has several rs232 ports and a ton of digital io ports to play with.  It has enough ram and rom to make a really nice little computer for coordinating other devices around the house and a really small footprint.  The problem is the boot loader is brand new and suffers from a couple of pretty severe bugs.  I left town for a few days and the device died.  No, I couldn't use the watchdog timer; a bug in the boot loader stopped me.  Seems that once you use the watchdog timer, you can't boot back up.  Sad.  I spent last night working up a timer interrupt to do basically the same thing by timing out and then checking a flag I keep resetting in the main loop.

Actually, this is a pretty elegant solution since I can decide within the timer interrupt service routine if I really want to reboot or not and set flags and such to act on when it comes back on line.  However, it is unfortunate that the darn boot loader hasn't been fixed yet.
Sketch to illustrate the Timer3 watch dog trick

#include <TimerThree.h>
// pick this library up at http://www.arduino.cc/playground/Code/Timer1
// scroll down the page to the Timer3 entry.

unsigned long resetTimer = 0;
unsigned long timerRate = 2000000;  // this is the MICRO seconds to wait between interrupts
int resetWait = 10000;                       // this variable is in MILLI seconds for how long to wait
                                                         // before resetting

void(* resetFunc) (void) = 0;             //declare reset function @ address 0

void resetMe(){                                 // There are certain compiler items that this little trick
  resetFunc();                                     // can over come.  Like putting this in a callback.
}

void checkActive(){
  // this routine gets called every timerRate (see above)
  // and here I check resetWait to see if the device has been
  // hung up for resetWait number of milliseconds
  if(millis() - resetTimer > resetWait){
    Serial.println("Fake Watchdog Timer Reset..........");
    resetMe();
  }
//  Serial.print("Timer3 at "); // uncomment these two lines to watch what's
//  Serial.println(millis());   // going on
}

void setup()
{
  int errorCount = 0;
  Serial.begin(57600);
  Serial.println("Initializing..");
}

boolean firsttime = true;

void loop(){
  if(firsttime == true){
    Serial.print("First time through loop, set up timer");
    firsttime = false;
    resetTimer = millis();
    // set timer3 to expire in 2 seconds.  So, every 2 seconds the checkActive routine
    // will get called and it will check the resetTimer variable to see how long in
    // milliseconds it has been since the variable was last updated.
    Timer3.initialize(timerRate);  // This sets timer3 to expire in 2 seconds
    Timer3.attachInterrupt(checkActive);
    // Note that this could have been in the setup() routine above, but
    // I put it here because sometimes I have a LOT of stuff to do during
    // the setup() routine.
  }
  // to test this, comment out the line below and the board should reboot.
  resetTimer = millis(); // This keeps resetting the timer
}


Update 10/29/2011:  I found a way to use the watchdog timer and documented it here.  The solution uses the watchdog interrupt as a timer interrupt and works nicely.  A little bit more code, but it is actually pretty cool.

Thursday, May 26, 2011

Updating the Blog

I updated the XBee and Swimming Pool pages.  They have links to the various parts to make it easier to find things.  I also added several items here and there.  Notable is the addition of my changes to the swimming pool solar heater to support the low flow rate my new variable speed permanent magnet pool motor (love saying that) can handle.  I can run the solar heater with as low as 5 pounds head pressure.  For you folks that don't understand that, this is a very good thing.  It means I can run the pool at about 270 watts during the peak period and still heat the water....for almost free.

Thursday, May 19, 2011

Modifications to my Power Display

As I mentioned in one of my posts, I've had a strange hardware failure in the WiShield used to gather data for the display.  Seems something there causes the Arduino to reboot.  I spent a couple of days looking for the problem and finally cut the script back to the point where the only thing running was the WiShield and it still failed.  I even went all the way to the example script and it failed there too.  That was actually the point where I started experimenting with XBees as a replacement network for the house.  Wifi is nice and does the job, but it is complex and takes a lot of code to keep running.  It has the advantage of being installed in laptops so you can watch it, being able to get to the internet, but what happens when the phone line dies?

Well, I finally got back to the display.  It stayed low on my priority list because the fail safes I built into the code were causing the display to come back to life in only a few seconds so it became an annoyance rather than a real problem.  I removed the WiShield and hooked up an XBee.  About 80 percent of the code disappeared!  I gather the power levels, time and temperatures from the various devices around the house and present them on the display.  The Pachube feed has been handled by my House Controller for a couple of weeks so that was removed as well.  Shortly, I'll update the Power Display page with the new script.  I'm going to keep the old script there as well for those folk that use Wifi, but this works really well.

Guess you can tell I'm pretty well sold on XBees as a network device for home automation.

Saturday, May 14, 2011

Swimming Pool Continued

Work on the pool controller is at its first stage of completion.  I can control the functions I want pretty well and have the devices in a weather resistant box mounted to the wall near my pool electronics.  It is on my XBee network and can be controlled from anywhere in the house since the XBees automatically forward data from remote nodes.  This was an incredibly cool (from a total nerd's viewpoint) project and actually does something useful.  Now I can set up timers to control what the pool system does and when it does it.  I already hooked it into my house controller and can lounge in my recliner and turn on the pool light at night to attract the bats.

You can see the web controls here <link>, but the buttons won't work for machines outside my home network.  A picture of the device, most of the code and description are under the 'Swimming Pool' tab above.