http://vectormagic.stanford.edu

My efforts towards good work
float iState = 0;
float lastTemp = 0;
#define PGAIN_ADR 0
#define IGAIN_ADR 4
#define DGAIN_ADR 8
#define WINDUP_GUARD_GAIN 10
float loadfloat(int address) {
// must be written
// this function return the float from EEPROM storage.
// This is used for the P,I, and D_GAIN settings.
// These are three values that need to be tuned after
// the machine up and running to make the PID loop
// work right.
}
float UpdatePID(float targetTemp, float curTemp)
{
// these can be cut out if memory is an issue,
// but they make it more readable
float pTerm, iTerm, dTerm;
float error;
float windupGaurd;
// determine how badly we are doing
error = targetTemp - curTemp;
// the pTerm is the view from now, the pgain judges
// how much we care about error we are this instant.
pTerm = loadfloat(PGAIN_ADR) * error;
// iState keeps changing over time; it's
// overall "performance" over time, or accumulated error
iState += error;
// to prevent the iTerm getting huge despite lots of
// error, we use a "windup guard"
// (this happens when the machine is first turned on and
// it cant help be cold despite its best efforts)
// not necessary. this makes windup guard values
// relative to the current iGain
windupGaurd = WINDUP_GUARD_GAIN / loadfloat(IGAIN_ADR);
if (iState > windupGaurd)
iState = windupGaurd;
else if (iState < -windupGaurd)
iState = -windupGaurd;
iTerm = loadfloat(IGAIN_ADR) * iState;
// the dTerm, the difference between the temperature now
// and our last reading, indicated the "speed,"
// how quickly the temp is changing. (aka. Differential)
dTerm = (loadfloat(DGAIN_ADR)* (curTemp - lastTemp));
// now that we've use lastTemp, put the current temp in
// our pocket until for the next round
lastTemp = curTemp;
// here comes the juicy magic feedback bit
return pTerm + iTerm - dTerm;
}
Here are some shots inside my new hut of joy. I put in the kerosene heater left over from out sweet days if living aboard. It makes a fantastic four season hang out. It will be interesting to see how warm I can keep it when the temperatures really drop.
I got a solid core door and put it up on saw horses. My Nantucket Ditty Bag works perfectly as a hanging tool organizer. Home depot had some big hooks for a buck that I can just screw into the bracing and add impromptu features to the hut.
Here is the canoe awaiting repairs. I stripped off all the electric parts for a good old fashioned paddle coming up this weekend.
I need a wider angle lens to convey how nice it feels inside, but this long shot gives the idea.