Thursday, December 8, 2011

Prototypical Stuff

Hola!

So I'm actually to a point on this thermostat that I'm ready to actually start building the PC board that contains controller and accompanying components (the smarts of the innards).  I've actually spent a few hours placing, soldering and wiring the parts on the prototype board.  This is tedious work to say the least, you are working with tiny parts and a soldering iron (which is essentially a pen shaped, skin searing device that rests at 700 degrees F).  Burned skin, strained eyes and fingers are consistently a by-product of this process.

Here is a front/back pic of the progress I've made so far; I'm at about 40% complete:



So at this point in the soldering process, already sick of it and looking for alternatives, I visited a few PCB (Printed Circuit Board) websites and found an awesome (fairly) new website and service setup for people making prototype PCBs.(Hey wait, I'm a people wanting to make protoype PCBs)  Making PCBs aren't very expensive, as long as you are getting hundreds of them made at a time, to make small one, it's quite expensive. 
The service that I found essentially takes dozens of submissions for boards from multiple customers and places them together like a puzzle on one big board.  Then it sends this large, completed puzzle off to get it printed.  When it gets this large board, it slices up all the pieces to distribute to everyone.  This way, the price is divided up among the dozens of people building boards.  BRILLIANT!!

So for about $15 I can design my own PCB and have it printed for me.  Screw all this start-from-scratch fabrication crap!  The downside is that there is a 3 week delay before I get the board back, but that's acceptable.

So, the last couple night's I downloaded the software used to design and route the board, read a few tutorials and got to work.  Within a few short hours, I'm almost ready to send off my first PCB!  Sweetness!! 

Here's a screenshot of the layout of the PCB:


I'll keep you posted when this baby shows up.  Stay tuned!

Sunday, December 4, 2011

Parts is parts

OK, so I've given you an inkling of what the thermostat is supposed to do and what it may or may not look like (if you're not up to speed, check out some of my earlier posts.)  I'm just SURE you guys are out there wondering, "What sort of black magic makes this thingy work??" Well, this magician is here to reveal his secrets...  (about the thermostat... don't get greedy.)

Well, the brains of this operation comes from a microcontroller, more specifically a PIC18F microcontroller.  Essentially, it's a small processor, think of an Intel Processor from a computer, circa 1985. However, if the Intel 8086 processor is your average pocket knife (it isn't), the PIC is a super utility Swiss Army knife (still an analogy folks, please don't try to open a can of ravioli with this.)  The 'micro' in microcontroller only refers to the size of the device, functionally, it should probably be referred to as a macrocontroller... or possibly a ginormo-controller.

The microcontroller (or ginormo-controller, if you prefer) keeps track of everything within the thermostat.  It reads the temperature of the thermocouple (a device that converts temperature to a voltage for the PIC to read), it controls the relay (an electrically controlled switch) that turns on and off the electricity to the freezer, it reads the inputs from the push buttons on the front panel, keeps track of time, stores the heating and cooling program sequences, and most ostensibly, controls the LCD screen on the front panel. And YES, it will indeed open up a can of ravioli, but only once, and other tools are probably required...

Much like the processor that's in your computer, the microcontroller runs a program.  To the microcontroller, this is just a list of binary numbers that are interpreted as instructions, it reads each instruction, one at a time, completes the instruction, then goes to the next instruction in the list.  To us, this same program is a list of instructions written in a programming language, in my case, the c programming language, which is a universal and very versatile programming language that has been around for a long time (it was developed in the early 70s).

Once I write the program using my desktop PC, I have to run it through a software program that compiles the c program into binary for the controller to understand and interpret. The binary program is then loaded and stored on some flash memory (same flash memory that's in a USB memory stick) embedded within the controller (did I tell you how cool this thing is??).   Once loaded and running, my particular program runs a repetitive loop that, essentially, reads the current temperature, updates the time, updates the relay outputs in response to the new temperature, then performs any screen updates if necessary.  Of course it goes into a different section of the program to create the user interface, menus and setup pages, but the majority of the time, the microcontroller is in a repetitive loop, repeating the same things over and over again.  Which is something I'm sure we can all relate to from time to time...


Summary for the skimmers:  Microcontrollers are very versatile, very useful and impressive, but a poor choice for a survival tool.


**Disclaimer:  I apologize for any extra geekiness that may have slipped out during this post...  I usually do my best to conceal that as much as possible.