Tuesday, June 28, 2011

SerialCouple - Thermocouple ADC

This is a device that takes a thermocouple temperature input, converts it into a digital value, and then spits out the temperature on a serial port, which you can then feed into a computer, or another microcontroller. This is a useful device for any time when you want to be able to monitor or log a temperature.
This also happens to be my very first circuit board design  This means after designing the circuit I wanted, I entered it into a PCB design tool (Eagle), and then laid out where I wanted each copper trace, solder point, and all the white text I wanted printed on the board.  I then emailed the board files to Laen, and two weeks later I got these professionally fabricated PCBs back in the mail, for only $9.90 for the three copies.
 How it works, is that a thermocouple screws into the two screw terminals on the right of the board (It's shown with three terminals, because that's all I happened to have in stock), a Maxim MAX31855 chip converts the signal coming out of the thermocouple into a digital temperature, which is then shifted over to the ATTiny2313 microcontroller (which is the bigger of the two ICs), which then processes the temperature and spits it out the serial port on the left.  The serial port is at 3.3V levels, not RS-232, but can be plugged into any FTDI USB adapter to be fed into a computer, since it follows the 6 pin TTL serial port standard.  The Maxim ADC comes in different flavors for each type of thermocouple, so even though I'm using it for K type thermocouples, changing it to use another type is nothing more than physically changing the 8 pin chip on the board.

For a first prototype, the PCB turned out pretty well.  I got about half the silkscreen on the wrong layer, so my name, website, and some of the part labels didn't print, and the 6 pin serial port header holes are too small, so they had to be surface tacked on.   All-in-all, its good enough to start working on the software for it before I spin a second revision of it.

A demo of the first working prototypes can be seen here.

Project files will be uploaded and documented on the project page.

Monday, June 13, 2011

Logic Shrimp - Free PCB Build

Dangerous Prototypes has a wonderful program where they give away blank PCBs of their prototypes.  I may or may not have spent eight hours last Sunday hitting refresh on their website while watching TV, trying to finally win a free PCB.  I built a Logic Shrimp, which is a four channel logic analyzer, which is super useful for debugging digital circuits.  I had a little trouble finding some of the parts, so here is the complete BOM for the Logic Shrimp on Digikey:
 And notice that many of these parts, particularly the passives, are very useful to have in stock, so where the list asks for eight 0.1μF caps, I would order 100.  Hope this list is helpful.

Friday, June 3, 2011

So You Want to Build Electronics

The equipment you need to get started in building electronics.
If you look back through the last two years of  posts on this blog, you'll see my relatively rapid transition from absolute beginner in electronics to someone who is formidable enough to have their work at least noticed (See HaD every other month).  This means I've been fielding a lot of questions from beginners online as to how exactly to get started, and what to buy, and what to do with it.  And to answer this, I keep having to pull up the same links to the basic stuff.
So lets say you're just getting into electronics and want to get really serious about it, or you're decently far into electronics and just want to see another person's parts shortlist, or you're me and my apartment burnt down right now and I have to restock my entire shop.  What to buy?

The obvious beginner answers are the juggernaut kits from places like the Maker Shed, and I will never knock them for putting together a perfectly reasonable starter kit (which despite your intuition, is actually reasonably priced), but I've never been really interested in them.  To drop $120 in one sitting on a kit which is half useful stuff and half stuff I don't explicitly need right now? Meh. I can appreciate the utility of someone else putting it all together for you when you have no idea what you need, but I'm much more of the opinion that I'll be happier sourcing the specific parts I want individually.

So here is a gigantic list of everything I would buy right now to replace my entire workshop if mine were to disappear.  I'm going to try and separate it into some sort of reasonable order as far as importance, but the point is that you see all of this, and use it as inspiration to put together your own collection.

Books - Online references will get you far, but the internet still can't beat the cohesiveness of a well-put-together book. 
  • Make: Electronics (Learning by Discovery) - When you've never used a breadboard before, you'll find this book helpful as it really holds your hand walking you through project.
  • The Benchtop Electronics Handbook - This is a great reference to supplement the Make Electronics book.  It is very basic, so it will help you get started, but it is unlikely intermediate or advanced hobbyists will find this at all useful.
  • TTL Cookbook, Lancaster - This book is invaluable as far as building discrete digital electronics such as 555 timers, counters, and any other kind of digital logic.  I was able to build a TTL clock based on nothing other than this book.
  • The C Programming Language, Kernighan, Ritchie - Once you move into microcontrollers, this book is all you need as far as pure C.  Admittedly, for however much it's great at teaching you C, it's terrible at teaching you programming, so if you've never programmed in anything else, I would recommend... something else...
  • Introduction to Algorithms, Cormen, et al. - Once you start trying to actually handle data on a microcontroller and generally move beyond blinking a single LED, this book is a nice book to at least have read through once at some point to know what to look for on Wikipedia.
  • The ARRL Handbook - This is a great book to own if you're going into analog electronics.  They release a new edition every year, which bothers me a little bit.  Just buy last years edition, and save some money.  I also found it useful to buy an edition from the 1980s on eBay, since they have many more projects using discrete parts instead of modern lumped IC design, which can give some insight on the matter.
  • The Art of Electronics, Horowitz -This book does assume you already have some familiarity with electronics, but has tons of cookbook circuit examples, which is my favorite way to learn electronics.
  • Noise Reduction Techniques in Electronic Systems - This is a relatively advanced book.  You won't find this particularly useful until you're designing PCBs or long cable interconnects, but it is an outstanding book on analog noise sources.

Equipment - This is where it gets a little hard because you can spend $20 on a soldering iron, and you can spend $10,000 on a soldering iron.  I'm going to try to recommend you get second shelf equipment, because the cheap stuff will just waste your time and be frustrating, but understandably, we're just hobbyists.
  • Needle nose, pliers, and wire cutters
  • Flush cutters.
  • Tweezers - Also get plastic ones if you're doing chemical PCB etching.
  • Dental picks - Very nice for scraping, poking, prodding, etc, while soldering.
  • Wire strippers - You'll usually see people using the combination wire strippers / crimpers.  I wasted too much of my life dealing with these before realizing how much better real wire strippers are.
  • Hot glue gun - Super useful for assembling prototype cases, insulating stuff, etc.  Just don't put it on anything that dissipates power like a linear regulator.
  • Blue tape - For crudely insulating joints, holding things together, and being a marking surface for hole positions on black plastic.
  • Screwdriver
  • Breadboards - I would buy a few columns more than what you think you need, because running out of space half way through a project sucks.  I have 5 single column boards, a two column board, and a 4 column board, which is a little excessive, but I got good deals on them from friends not wanting them after our college electronics classes, and it's nice being able to have a few different prototyped projects sitting around at once.
  •  Breadboard wires - These are reusable, but at some point you do need to start culling the used ones and replenish the kit.
  • Clip leads
  • Coin envelopes - These are surprisingly useful for storing different values of resistors, or diodes,or anything else tiny.
  • Altoid tins - I love these tins for basic project boxes, as well as storing bulkier components such as transistors and crystals.
  • Solder sucker / Solder braid - Once you start soldering parts together, you're going to start making mistakes soldering parts together.  These undo those inevitable mistakes.
  • 30x Jewelers loupe - I use this ALL the time to check for solder bridges and cold solder joints.
  • Volt / MultiMeter - Repeat after me: do. not. buy. the. $15. one. at. the. hardware. store. Also make sure you have a spare fuse in stock for this. You will only ever blow your amp meter fuse when you're using it.
  • Test leads - Volt meters do come with a set of test probes, but it's worth investing in a seperate kit that has all the interchangeable points (microclip, spades, alligator clips, etc)
  • Power supply - I managed to find a nice power supply where someone mounted an ATA computer supply in a box with screw lugs for 3.3, 5, 12, and -12V.  You can go for a fancy variable supply, but I didn't. At the very least you'll want a nice breadboard power supply and a 9V wall wart.
  • Banana plug test leads (to alligator or mini-clip) - I use these to connect projects to my power supply more than anything else, but they also plug into the posts on the top of all mounted breadboards, so they have all kinds of uses.
  • Soldering Iron - I own the last generation Hakko 936, but it's safe to assume the more recent 888 model is just as good.  The difference between a $20 soldering iron and a $100 soldering iron is amazing.  Being able to turn the iron down to 300C and not worry about destroying PCBs makes soldering a lot easier.
  • Tip cleaner
  • Fine gauge solder - I use .032 diameter solder, and even that is a little thick some times; the finer the better. I also have some 0.1" solder for bulk heat-sink or strain joint soldering, but its use is rare.
  • Helping third hand - When you're soldering, these are priceless.
  • Calipers - I use these more for my mechanical engineering projects, but is still useful for measuring clearances and pitch.
  • Oscilloscope - The holy grail of the hobbyist shop.  Consumer scopes have finally gotten to the point where they're reasonably priced and GOOD.  A lot of companies have started coming out with toy USB or iPhone oscilloscopes, and I'll just remind you that they really are just toys.  Remember that the scope isn't going to do you much good without probes, so do some research and pick out the specific probes and cables you want to use with your scope, and expect to spend some money on these as well, because a good scope with bad cables is going to waste your time.

Development tools - I personally live in the AVR and MSP430 camps, but the choice to get into developing on PIC, or 8051, or ARM, or anything else, is completely arbitrary.
  • Arduino - There is the endless debate about exactly what board the beginner should start with, but as far as I'm concerned, the Arduino answered the "first" board question and closed the book.  Now, once you start getting more advanced, you will want to move off the Arduino to more specific boards, but you have to start somewhere.  Make sure to get the non-surface mount Arduino unless you have to, because replacing damaged SMT chips is a pain, where replacing damaged DIPs is trivial.
  • USBtinyISP - Once you want to start making more AVR ATMegas to plug into your Arduino, or want to move to smaller AVRs like the Tiny2313 or Tiny85, or bigger chips like the Mega1284, you're going to need an in-circuit-serial-programmer to plug into the 2x3 header you see on your Arduino and elsewhere.  The Adafruit kit is only $20, and works perfectly well for hobbyist applications.
  • Once you get on your feet on the Arduino, the number of possibilities  really opens up.  Do you stay with AVRs, or move to other architectures, such as:
    • PICs using the PICkit.  PICs were the 8 bit behemoth before the Arduino came in and took the hobbyist market by storm.
    • MSP430 using the Launchpad.  MSP430s are a very wide line of 16 bit controllers, but suffer from the disadvantage compared to many PICs and AVRs that it only runs on 3.3 volts, not 5V.
    • 8051 - The 8051 is a classic microcontroller architecture you'll find in tons of places you don't expect it.  Probably the most popular hobbyist application of 8051s is the TI CC111x chips in things such as the IM-ME.  The programmer I use is the GoodFET, which I happen to sell assembled here.
    • The list goes on, with all kinds of other architectures like ARM and other vendor-specific controllers.

Components - This is where we really get to what I have in my boxes of electronics.  More than anything else, this is defined by what type of electronics or projects your working on.  The best way to stock this, is to put together shopping lists for each project and then just buy 5x what you need.  Eventually you collect enough stuff that you can just sit down and build.
My collection has spiraled to 8 12" Digikey boxes, so this is obviously not everything I own, but after getting this, almost any project will only be a few specific parts away from being doable.  If you're going for diversity, you might be able to beat out the passives with entire kits, but I just prefer to buy the individual values I want.  Living in the Silicon Valley means I usually get most of these at salvage electronics stores in the area, which means a lot of the passives come in $1 hundred-count bags, but I'll link to Digikey to make your life as a nebulous internet reader easier.
  • 10x each size of 5% 1/4W resistor: 100, 330, 1k, 4.7k, 10k, 100k. - Now this is incredible sparse, but is plenty for digital, where you just need current limiting and pull-up resistors, so if you instead want to just buy a complete kit and be done with it, that wouldn't be a bad decision.
  • 10x each capacitor: 22pF, 0.1μF, 100μF. - Digital really only needs a single value for every few decades.  Any analog work will require a much larger variety of cap values, so again, if there is any interest, feel free to buy a complete kit.
  • 1x 500μH inductor for buck charge pumps.
  • 5x 8DIP, 20DIP, 28DIP socket
  • 10x 2N3904 NPN, 2N3906 PNP transistors - I also have higher power transistors and MOSFETs for heavier duty, but these will get you far in driving a few LEDs.  As far as higher power ones, good ones to start with would be the 2N2222, and then probably go to the MOSFET IRF820.
  • 3x 2N7000 - MOSFETs are interesting because, unlike bipolar transistors, they are voltage controlled instead of current controlled, which is sometimes useful when you need control signals with very little power behind them.  I've never done anything with P channel MOSFETs, but ZVP2106A would be a good FET to get you started playing with those.
  • 10x 1N4007 - High power diode. Most applications will require less than 1000V reverse-voltage, but it's easier to just stock one diode that can handle everything, than to try and save a few cents by using 1N4002 in one project, 1N4004 in another, etc etc.
  • 10x 1N4148 or 1N914 - These are the classic small-signal diodes, that don't handle current well, but are useful for diode logic and signal isolation.
  • Quartz crystals: 32k, 16MHz - These are for precise clock sources for time-critical projects like clocks or high-speed serial communication.  Microcontrollers particularly can choose between running off a crystal and running off their internal oscillators, but it's the difference between them being a few percent accurate, and them being 20ppm (0.002%) accurate.  Particularly for the 32k crystal, the load capacitance can be important, so check to see if your application needs the 6pF or 12.5pF variants, or else it might be a little off frequency. Between the DS1307 and MSP430s I use, I only ever need the 12.5pF one.
  • 7805 / 317 - Linear voltage regulators aren't very efficient, but easily let you take something like a 9V battery and turn it into the 5 volts digital circuits need.  There are better, more modern regulators, so be sure to browse manufacturers websites for such.
  • 5mm LEDs - These tend to be available in bulk bags on eBay, etc, so getting a bag of 100 will probably save you quite a bit of money if you ever think you're going to build something that uses more than one or two.
  • Copper clad perf board - For when you want to solder down your prototype after breadboarding it, but don't want to make custom circuit boards.  Many beginners also like the breadboard shaped perf board, which allows you to copy point for point the circuit you built on your breadboard.
  • 22 gauge wire - I got a huge spool of this at the hardware store before metal prices took off 10 years ago, but even just getting a few dozen feet would be plenty for breadboarding and small projects.  Getting 22 gauge is important, since 20 gauge will damage the clips in breadboards for being too large, and 24 is a little too small and will tend to fall out. 
  • Male and female header - These are rows of pins and sockets that can plug into each other, or can be used as connection points for jumper wires.  You can buy them in the specific lengths you need, but male header is designed to snap apart, and with female header you just crush the next socket over with wire cutters to cut them to length.  Male: straight, right angle, Female: straight, right angle.
  • Push buttons, switches, DIP switches, etc
  • Fun displays - Seven segment LEDs, dot matrix, HD44780 family LCDs, etc.  I've got a whole box full of various segmented and matrix displays I've collected over the years both online and at salvage shops like Halted. You'll save a lot of money getting these things on the second markets, so I'd urge you to spend some time looking through them for inspiration, instead of looking for a specific display.
  • Batteries and battery clips - The common standard for 5V projects is using a 9V battery and a 7805 regulator, but the small capacity of 9V batteries always bothered me, so I prefer AA clips, but do use both.
Digital electronics - Where everything before this was pretty general, this is where my emphasis in digital electronics becomes apparent.
  • ATTiny85, ATTiny2313, ATMega328, ATMega1284 - I've found that having these four AVRs tend to do a good job covering the spread from the smallest to largest projects you would be doing with an 8-bit controller.  I tend to keep a pretty flush stock (5+) of each of the first three, since Atmel has a habit of not having chips in stock for several months at a time.
  • MSP430G2231, MSP430G2452 - The two top of the line 14 pin and 20 pin MSP430G2s for the Launchpad.  These only run on 3V, but I've found them quite useful in lower-power applications.
  • 555 - This is the classic timer chip, useful for button debouncing, buzzers, crude oscillators, etc. There have been some pretty impressive projects done using the 555.
  • 4N35 - This is a good logic-level optical isolator.  These are a tiny LED and photo-transistor in an IC package, such that you can couple a signal from one circuit to another entirely optically, while avoiding connecting any wires between them, which is useful in electrically noisy environments, or where you need to worry about high voltage risks.
  • DS1307 - A very nice I2C real time clock chip, with a battery backup option and 56 bytes of user RAM.  I've used this for when you want to be able to switch off the microcontroller at large, but still keep track of the time of day and whatever program state you save in the extra RAM.  I've built a DS1307 target board before for breadboarding.  For more demanding time-keeping needs, I would go with the surface mount DS3232 chip, which is an order more accurate.
  • 24 series I2C EEPROM / 25 series SPI EEPROM - Though most controllers come with a few hundred bytes of EEPROM on-chip, if you plan to be logging a large amount of information, you'll want an additional EEPROM chip.  The difference between the 24 and 25 series is that I2C is much slower, but if you already have an I2C bus in your project, you can chain up to 4Mbits (or up to 8 chips) of EEPROM on the bus for free.  SPI on the other hand can be run quite a bit faster, but costs an additional IO pin per chip, in addition to the 3 wire bus.  For larger storage needs, I would look at SPI flash chips, or even go for (micro)SD cards.
  • DS1631 - A nice I2C temperature sensor.  I've used these in thermometers, thermostats, and temperature data loggers before. 
  • 74HC595 - The be-all end-all series-to-parallel shift register.  This lets you use three IO pins on a microcontroller to control as many outputs as shift registers you're willing to chain together to get more digital outputs for your project.
  • As much other 74XX logic as you can handle - If you want to work below the level of a microcontroller, you can do a surprising amount of stuff just using logic gates.  Other than my TTL clock, I've mostly just used 74AHC125, 7447, 74141, and 7414 chips for "glue logic," where it acts as an interface between different signal types.  Unfortunately, a lot of the 7400 series are getting a little difficult to get new, so eBay will be your friend in trying to source some of the older chips.
  • In addition to 7400 logic, some of the CMOS (4000 series) gates are kind of useful too.  A classic one for scrolling LED progress indicators, etc, is the 4017, but again, the list goes on.
  • Now spend a lot of time browsing through Texas Instruments and Maxim's websites to get inspired by LED drivers, DACs, ADCs, IO expanders, the list goes on.
Analog chips - I admittedly don't do much analog work, but these are the basics when you want to get into it.
  • The classic beginner general-purpose op-amp you'll probably see others using is the 741, but it is actually a really poor op-amp.  Schools love to use it because it demonstrates almost everything that can go wrong with an op-amp.  You should probably stock more recent models, which are just as cheap, such as the LM324 or TL072/82 for higher end work.
  • 386 - This is a great amplifier when you really don't need an entire op-amp, but just want to make some audio signal LOUDER.  Bypass capacitors between the power lines is a must, because this chip tends to be unstable and "motorboat" if the power rails aren't filtered properly.
  • LM339 - This is a comparator chip, which is essentially an op-amp with the gain turned all the way up so it just tells you whether one signal is higher than another.
  • If you really do start trying to build analog circuits, this is the time to buy a complete resistor and capacitor kit, because it will drive you nuts when you need to increase a capacitance by 10% and you only have three different size capacitors.

Now of course, this is just the tip of the iceberg as far as electronics really goes.  There are so many different directions to go with the hobby, and so many parts to do it with, no list will cover all of it.  I would never expect you to sit down and buy all of this at once, so use this list as more of an inspirational list than a shopping list.  You don't need anywhere near all of this to get started, but you'll find you'll tend to collect most of it over a matter of years in the hobby.  If reading through this there are any glaring omissions of classic beginner parts, make sure to drop me a tip in the comments!