Showing posts with label fan. Show all posts
Showing posts with label fan. Show all posts

Sunday, January 27, 2013

ProtoCylon: Control

ProtoCylon: Control

By Bobby Neal Winters

Again and again I am reminded of the importance of the basic model:  Input information, Process that information, and Output (or Act on!) the processed information.  This simple model helps us to keep the processes separate and keeps us from confusing them.  Indeed, once we understand various, separate processes, we can mix and match ways of inputting with ways of outputting.
This brings us to today’s project: Temperature control.  One way I justify this new hobby of mine to the Other Half is that one day I can use it to control the fan for the greenhouse next door.  The fan has to be turned on when it gets too hot.  
During the summer, there are some days we simply have to anticipate that it will be hot before it actually gets hot and think to turn on the fan before we go to work.  If there were a temperature control for the fan, we would neither have to remember to turn it on in the morning or turn it off in the evening.  
Today’s project will turn a fan on and off at a certain threshold temperature.  It won’t control a fan as big as the one in the greenhouse, but I am into the “baby step” thing.
For the input part, I refer my reader to my last blog entry on Telling the Temperature.  In that, I construct a temperature sensor that connects to the Arduino with one wire.  The sensor itself is a surprisingly tiny component.  You can get ten of them for fifteen dollars.  This is input at its best.  You don’t have to type in anything; you don’t have to turn a dial; you just connect it and let the software do the rest.
The control in this case is easy as well once you have the transistor wired in.  To control the fan, I refer the reader to Beginning Arduino by Michael MacRoberts in the section where he shows how to use a TIP120 transistor to control a motor.  
Transistors are kind of scary to me.  I still don’t understand them very well.  This I know: They have three prongs.  One of the prongs goes to power, one goes to ground, and the third (actually the middle one) connects to the Arduino where it gets instructions for controlling the flow of current.
All of the complication of this project took place on the breadboard.  Wiring the temperature sensor and the transistor are still non-intuitive to me.
The code is simple:

// include the library code:
#include
#include

//Temperature Sensor pin
#define ONE_WIRE_BUS 3

//Pin that controls the transistor

int transistorPin=A1;

// initialize the library with the numbers of the interface pins
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer, outsideThermometer;
//place to put the temperature
float tempC=20;

void setup() {
 //Set up transistor
 pinMode(transistorPin, OUTPUT);
 // Get the temperature sensors running.
 sensors.begin();
/*The 0 in the second argument is because this is the first transistor.  Computers start counting at 0.*/
 sensors.getAddress(insideThermometer,0);
}

void loop() {
 //Get the Temperatures
 sensors.requestTemperatures();
 tempC=sensors.getTempC(insideThermometer);
 //Is it hot enough for the fan?
 if(tempC>25){
     //Turn the fan on
     analogWrite(transistorPin,255);
 }
 else{
     //Turn the fan off
     analogWrite(transistorPin,0);
 }
 //No reason to be impatient
 delay(1000);
}

Saturday, May 21, 2011

Multimedia Computer: The Ubuntu Mindset

Last Monday I wrote in this space that I had succeeded in getting my Multimedia Computer running and that I had installed Ubuntu on it.  This was a great victory for me.  At the time, it gave me a great feeling of victory that I didn't want to dilute.  A few days have passed now, so I feel I can share more of the truth without spoiling that feeling of victory on my part.

It is still running and functioning fine as a computer, but I there are certain issues involved with making it function as a Multimedia computer.  One of these is the fan.  The original fan that it came with didn't have a plug to attach it to the fan plug on the motherboard.  I thought I'd fixed that by buying an adapter.  The adapter arrived; it is male.  I needed a female. (Insert joke about Ubuntu computer geeks here.)

No problem.  I had an old cheap fan purchased for an old project laying around.  I installed it.  I now remember reading a review of it with PROS--it is cheap, CONS--it is noisy.  That noisy part is being glossed more me even as I write this.  I currently have a female adapter on order.  Ten minutes of work will suffice to fix this.

The next issue is software.  Windows 7 comes with Windows Media Center installed.  You just sit down and run it.  The Ubuntu experience is different.  And it now becomes clear to me what the Ubuntu experience is all about.  To fully explain it, at least to my own satisfaction, I need to go back to the Bible.

In Genesis, when Jacob and Esau are introduced it says: And the boys grew: and Esau was a cunning hunter, a man of the field; and Jacob was a plain man, dwelling in tents. To me this says that Esau like to push the edges of existence and do things that were hard.  Jacob, on the other hand, liked to enjoy the fruits of what was then modernity.  Were this written today, the description of Esau would remain the same while Jacobs might be described as a man who like living in houses with beds and indoor plumbing.

Some of you may already be ahead of me in transferring this to the context of computers.  Esau would be pushing to that more challenging mode of existence with Linux while Jacob would use Windows 7.  (Macs would correspond to whatever they were using in the fleshpots of Egypt for those of you who wish to push this a little farther.)

I grew up on the frontier, starting with a TRS-80 and moving to an Apple IIe and then finally hitting the PC river, as it were, more than twenty years ago.  I've been watching the frontier disappear ever since as we've moved from floppies to hard disks and CDs and DVDs and USBs.  Then came the Internet and the Cloud may supersede it all.  I've gone through all of the contortions that we had to back in the good old days just to get something to print for Heaven's sake.

All of those contortions are why we developed things like Windows 7 and Snow-frickin-Leopard and all of those other things.  Friends, let me tell you, as much as we gripe about these OSs, they ain't so bad.  They beat the Hell out of walking three blocks across campus to access your e-mail from a Unix account and download the file that was sent you using Kermit.  I was younger then, everything did work right, but that rosy glow doesn't make me think I'd like to do it that way all over again.

That being said: This is a hobby.  We do hobbies to stretch ourselves in safe, controlled ways.  I can pretend that I am back on the Computer Frontier as it was in the days of old, but do it while safely living in the modern world.

In other words, I've moved out of the hardware faze and into the software faze which is presenting a new challenge to me.  I will keep you updated, but now the smell of the spring flowers is calling to me.