Thursday, November 29, 2007

Magically Vectorious

My friend Daniel pointed me to this awesome site at stanford that will translate raster images to vector.
http://vectormagic.stanford.edu


PID code for Arduino

Here is my PID code for Arduino or other microcontroller.  It is unfinished and untested in this exact state, but it used to work on a PIC, so it cant be that broken, right?  Once I get a chance to get it uploaded to my espresso machine and tested IRL, I'll publish it on the arduino wiki. If you use this and especially if you change it, please drop a quick comment. (license at bottom) thanks!


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;
}



Creative Commons License


This work is licensed under a
Creative Commons Attribution-Noncommercial 3.0 Unported License.

Tuesday, October 30, 2007

Inside Quonset Nation

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.

Wednesday, October 24, 2007

Fort Quonset

Here are three photos from the construction of my new favorite
place! I found this made in the USA Clearspan brand tent on close
out at farmtek.com. I ended up building a floor from cheap chipboard
subflooring that is unfortunately full of bad chemicals. Under the
chip board I used free scrap wood from Lowe's to level it all out.
Materials for the floor ended up under $100. By the way, I didn't
knock that fence down. Its rotting of its own volition.



The steel frame consists of seven arches. I ordered one extra set over the standard six to decrease the spacing to 40" and beef up the structure to better manage any heavy snows. Though, I frankly don't think it would have been an issue with a structure this size. Though you are specifically warned in the instructions not to climb or hang on the structure, I hung on it anyway. Rebel! Its strong though! I set up little tabs of 2x4s sticking out from under the floor to support the ends of the poles.




Here is it all finished! I have started to move in. My canoe is safely stored inside now, and I am planning to setup a four season outdoor social space and small shop area. I even hung our hammock up inside and gently tested it out. There was a little flex, but it actually holds me up in the hammock quite well. The whole tent weighs 500 lbs and is excellent quality overall. It will be a great place for projects and enjoying the back yard all year round.

Monday, October 15, 2007

I heart Arduino

I wrote the first version of my espresso machine project in MPLAB for a PIC. I lost many hours just getting a power supply setup and subsequently frying parts and getting confused when I powered them wrong, or had mistakes in wiring. I suppose I don't have to call those hours "lost," but after spending 3 hours debugging code to realize that I've made a wiring mistake is pretty freaking frustrating.

I am starting a new revision of my machine mod. I am planning to add a realtime clock, water level sensor, and improved interface. On a tip from my friend Casey, I checked out Arduino as a base for this second revision. Arduino has been developed particularly to bring electronics to first time users and has been adopted by artists, musicians, and designers all over the world. For me, its just a huge relief, and has brought a much higher fun ratio to my espresso hobby. My three favorite aspects of using arduino are that i can work in OS X, it uses a USB bootloader, and other people might be able to use my software and hardware designs for their own purposes. Its already catching on, but I expect that Arduino (and wiring) will continue to gain in popularity.

Learn lots more about arduino here: http://www.arduino.cc/