Monday, March 30, 2009

University of Toronto Life Sciences

I just got accepted into the University of Toronto Life Science program. Awesome!

Saturday, March 28, 2009

Some interesting electronics/hobby/microcontroller sites Your Electronics Open Source Youritronics: DIY, Electronics, IT and Gadgets Embedded projects from around the web

Thursday, March 26, 2009

DIY Reflow Soldering

I recently ordered a whole bunch of samples and high end integrated circuits from various companies such as Maxim, Austria Microsystems and Microchip (such as the PIC32). These chips are all really cool. However, there’s a problem. They’re all surface mount. It has become a trend for companies to offer high pin count and new devices in surface mount packages only. This is bad news for prototyping (especially for hobby use) because surface mount packages don’t fit in breadboards. However, it is very much possible to make PCBs with fine-pitch pads/traces for even up to 0.4 mm TQFP chips such as the PIC32 100 pin versions. However, the problem now becomes the soldering.

There are two ways that a hobbyist can attach surface mount chips to PCBs:

  • Traditional soldering iron with lots of flux and a fine tip. Or,
  • Homebrew reflow soldering, which is what today’s post will examine

For complete newcomers to the topic, the process of reflow soldering is outlined below:

  • A special type of solder known as solder paste is applied to the surface mount pads on the PCB. The solder paste very think and acts like glue.
  • The surface mount components are then populated on the PCB on top of the solder paste. Due to the viscous nature of the solder paste, the devices stay in place.
  • The entire board is then slowly heated to a certain temperature enough to get everything warm (around 100 degrees Celsius for 2 minutes). Then temperature is quickly increased to around 200 degrees Celsius for the solder paste to melt.
  • At this point, the solder paste melts and attaches the devices to the pads on the PCB.
  • The PCB is cooled slowly and is ready for use.

Reflow soldering makes it very easy to solder very fine pitch components. All you need to do is apply solder paste to the pads, place and align the device properly, and melt away. Fortunately, hobbyists have several ways to go about making their own reflow “oven”, as outlined below:

  • A conventional toaster oven can easily heat up to temperatures required to melt solder paste. Toaster ovens are also inexpensive and are commonly used by hobbyists as reflow ovens.
  • Another way to go about reflow soldering is by using the stove top or a hot plate or a skillet.
  • A third, less common way is to use a reflow station or a hot air gun. Engadget has a really good article on how to make such a device very inexpensively.

However, since the “temperature controls” on most toaster ovens, skillets, hot plates and stove tops is next to useless, it is important to measure the temperature of your heating device beforehand to become accustomed to the temperature at a certain setting so as not to overheat your PCB and potentially damage components.

There are also numerous videos on youtube regarding homebrew reflow soldering using various techniques including toaster ovens, stove tops, skillets and even hot air guns.

Sparkfun has a few very nice tutorials as well: (look in the “Surface Mount Soldering Tutorials” section).

I also asked a whole bunch of questions regarding homebrew reflow soldering on the PICLIST. Here are my questions:

1. I thought heat damages components. I was consistently cautioned not to overheat components during hand soldering. If the idea is to heat up the solder just enough to melt (and maybe a bit more so as not to form a "cold soldered" joint), then wouldn't reflow soldering do the same damage to components?

2. One of my DIP chips came with a notice saying that it should be "cooked" at 125 degrees Celsius prior to reflow soldering. I would never reflow solder a DIP chip, but this is interesting. Why do they have such requirements? Is it because of any possibility of trapped moisture in the chip that could rapidly expand in high heat and damage internals? What's the worst case for not obeying this notice?

3. I've also heard of reflow soldering "profiles". What exactly are these profiles? Is it a requirement that I adhere to them for homebrew reflow soldering projects?

4. How do I apply solder paste on pads? Do I just squeeze it out of the tube and rub it consistently over the pads so that all of it is connected? Does a very precise amount need to be applied discretely on each individual pad? How is this done?

5. Where to buy solder paste, are there different types, what brand, what type? Should I use flux? Should I pre-flux the pads or apply flux and then solder paste?

6. I've also heard that it is wise to calibrate or know where your skillet/stove reaches a certain temperature. What temperature is good for reflow soldering? How do I measure this temperature?

7. How long should the PCB be on the skillet/frying pan during the reflow soldering process?


Here are some other questions that I had formed based on the answers given by the PICLIST members:

8. How long does the solder paste usually keep (before it goes bad)?

9. Also, do you recommend closed ovens or open type frying pans/skillets/etc?


I got some very useful and interesting answers from the good folks at the PICLIST. I thank all members of the PICLIST who have taken the time to write detailed replies to all of my questions. Here are some interesting replies from the members:

Answers to Q #1:

Herbert Graf:

Almost all components are DESIGNED for reflow, so no, they won't be
damaged by it, assuming you follow a recommended profile.

Joseph Bento:

Yes, heat damages components.  It's the way the heat is applied,
however.  A solder iron may have a tip temperature of over 400c.  At
this temperature, you need to complete your connection quickly or else
risk damaging the component.  If you use an oven with paste solder for
SMT components, you will typically limit the temperature to around
200c.  Paste solder turns liquid at around 170c.   I have hand
assembled many boards with SMT components and have never seen a
component damaged in a 200c oven.

Jesse Lackey:

Parts are sturdier than you think.  Just don't be on the super hot for a
long time.

Answers to Q #2:

Herbert Graf:

Bingo. Think of a kernel of popcorn. Heat it up, it explodes. Same with
a chip. If you don't dry it out by "cooking" it, it will rupture during
reflow. The main issue is the damage may not even be apparent, very hard
to debug issues could result.

Olin Lathrop:


Answers to Q #3:


Profile is basically a temp vs time graph, that shows you what the
temperature should be at a certain point in time. What it boils down to, is
you need to preheat the board at a lower temperature (preheat), then quickly
raise the temperature so the solder paste melts (ramp-up), then cool the
board, but not too quickly (ramp-down).

Answers to Q #4:


Take a small syringe, carefully file off the sharp end to make the end flat,
then use it to dispense solder paste. See this page for info on application
You don't need to be too precise, you just need to dispense the right
amount. Reflowing is self-correcting, to a point.

Olin Lathrop:

In real production, this is done with a stencil.  The stencil is usually
thin steel of a specific thickness.  The solder paste is sortof squeegied
accross the stencil so that it gets wiped off the stencil but blobs remain
in the voids formed by the holes in the stencil.  The stencil is then lifted
off the board and just the blobs of solder paste remain.
For one-off home use, you'd probably apply the paste manually with a
syringe, and then expect to fix a few shorts afterwards.

Herbert Graf:

The pros have a mask and basically use a silk screen technique to get
the past on the board. While much more time consuming, simply squeezing
the paste on the pads will work pretty much just as well. Don't use
alot, experience will tell you how much. If you use to much chances are
either the joint will be rubbish, or you'll get a sometimes very had to
see bridge.

Answers to Q #5:

Mark Rages:


There are more links for where to buy the paste, but I have to carefully dig through the ever expanding thread. There are also lots more answers and questions on the thread, but these are the ones that I felt were most important.

Sunday, March 22, 2009

Peltier Elements

A Peltier element is a metal element which passes heat from one side to the other when a current is passed through the element. So one side gets really cold and the other gets really hot. They’re inexpensive and compact. Solid state as well. Seems interesting, could possibly be used to make a drink cooler or something similar.

Saturday, March 21, 2009

Logic Families

Some information I found on different logic families.

Device Families:

TTL (74xx)  True TTL    
74L         Low power   
74S         Schottky    
74H         High speed
74LS            Low power - Schottky                
74AS            Advanced - Schottky         
74ALS           Advanced - Low power - Schottky                
74F(AST)    Fast - (Advanced - Schottky)        
74C         CMOS...................check Vcc levels     
74HC (U)    High speed - CMOS (Unbuffered output)        
74HCT           High speed - CMOS - TTL inputs            
74AHC           Advanced - High speed - CMOS                
74AHCT          Advanced - High speed - CMOS - TTL inputs   
74FCT (-A)  Fast - CMOS - TTL inputs (speed variations) 
74FCT (-T, -AT) Fast - CMOS - TTL inputs (speed variations) 
74AC            Advanced - CMOS                             
74ACT           Advanced - CMOS - TTL inputs               
74FACT          AC, ACT (Q) series                      
74ACQ           Advanced - CMOS - Quiet outputs                 
74ACTQ          Advanced - CMOS - TTL inputs - Quiet outputs

   Bus Driver Families 

74ABT           Advanced - BiCMOS - Technology                 
74ABTE          ABT - Enhanced Transceiver Logic                
74ABTH          Advanced - BiCMOS - Technology - bus Hold   
74BCT           BiCMOS - TTL inputs                        
74BTL           Backplane - Transceiver - Logic             
74GTL           Gunning - Transceiver - Logic               
74GTLP          GTL Plus                                

   Low Voltage Families 

74ALB           Advanced - Low Voltage - BiCMOS                 
74LV (U)    Low - Voltage (Unbuffered output)           
74LVC (R) (U)   LV - CMOS (damping Resistor)(Unbuffered output) 
74LVCH          Low - Voltage - CMOS - bus Hold                 
74ALVC          Advanced - Low - Voltage - CMOS                 
74LVT (R) (U)   LV - TTL  (damping Resistor(Unbuffered output)  
74LVTZ          Low - Voltage - TTL - High Impedance power-up   
74ALVC (R)  ALV - CMOS (bus Hold) (damping Resistor)    
74ALVCH         Advanced - Low - Voltage - CMOS - bus Hold  
74LCX           LV - CMOS (operates with 3v & 5v supplies)  
74VCX           LV - CMOS (operates with 1.8v & 3.6v supplies

4000            True CMOS (non-TTL levels)              

  ECL Device Families:

MEC I           8nS*                
MEC II          2nS*                    
MEC III         (16XX)  1nS*  .......* = Rise & Fall Times  
101xx           100 series 10K ECL, 3.5nS*              
102xx           200 series 10K ECL, 2.5nS*              
108xx           800 series 10K ECL, voltage compensated, 3.5nS* 
10Hxxx          10K - High speed, voltage compensated, 1.8nS*
10Exxx          10K - ECLinPS, voltage compensated, 800pS*  
100xxx          100K, temperature compensated                   
100Hxxx         100K - High speed, temperature compensated  
100Exxx         100K - ECLinPS, temp, voltage comp., 800pS* 

QtCreator – Trolltech’s Own IDE

I didn’t find out about this amazing IDE until I was browsing for themes for my KDE 4 desktop on and saw an interesting looking icon in one of the theme screenshots. Curious, I googled the icon name (qtcreator) and was pleasantly surprised to find out that it was Trolltech’s own IDE for Qt.

It’s amazing. Really easy to make anywhere from quick and simple GUIs to complete and complex applications. The source editor is really cool too. The IDE looks nice, loads fast, feels slick and is available for Linux, Windows and Mac. Completely free.


More Hobby PIC18 Devices

The best hobby chips are: (spaces added in part numbers for readability)

  • PIC 18 F 26/46 20 – Very robust, but a bit more expensive ($5.50), 100 K flash write cycles (the two below only have 10 K flash write cycles)
  • PIC 18 F 26/46 K 20 – Low power
  • PIC 18 F 26/46 J 50 – Low cost ($3.30), 2 – 3.3 V, 5.5 V tolerant digital inputs, USB, peripheral pin select, RTCC
  • PIC 18 F 2550 – USB

The 18F26J50 definitely seems cool. Note that the 46 models (as opposed to the 26 models) have higher pin counts and therefore, more ADC channels. Both come in DIP packages – very hobby friendly. The only trouble with the 18F26J50 is that it has a maximum voltage of 3.3 V.

Thursday, March 19, 2009

Microcontrollers for Hobby Purposes

If you want to dive right into the art of electronics and microcontrollers, choosing the right chip might be a bit difficult. Microchip alone offers hundreds of different microcontrollers with many different cores and series. In today’s post I’ll list a few good microcontrollers that are inexpensive, readily available, have lots of RAM, flash and onboard peripherals.

I’ll start off with Microchip’s microcontrollers. Generally known as PIC microcontrollers, they’re  one of the most popular (if not the most popular) series of microcontrollers out there. However, there are many different series of microcontrollers that Microchip offers.

  • 10F – these are the lowest of the low end of PIC microcontrollers. They’re generally used for very specific purposes in large production quantities since they’re extremely cheap. Stay away from these as they have very little flash and RAM.
  • 12F – these are known as the low end PICs. Not many onboard peripherals but a reasonable amount of flash and RAM.
    • In this series, it’s good to buy a handful of the 12F683 chip.
  • 16F – these are known as the midrange PICs and are probably the most popular hobby microcontrollers. Inexpensive, a solid amount of flash and RAM, good pin count, lots of onboard peripherals.
    • A good chip to buy here is the 16F886.
  • 18F – these are known as the high end PICs and have lots of RAM and flash. They’re slightly more expensive but since we’re not dealing with production quantities of 100 000 chips, cost is negligible. Lots of onboard peripherals, lots of RAM and flash. The extra flash and RAM is well suited for C compilers as well.
    • Go for the 18F2620, which is pin compatible with the 16F886 but boasts a lot more features.
  • 16 bit series – these are also really cool and are 16 bit but I don’t really see a reason to buy these over the 8 bit chips outlined above. However, Microchip does offer the C30 compiler for these chips which is based on gcc so there are a few advantages.
  • 32MX – these are Microchip’s top of the line 32 bit microcontrollers. They cost around $10 each for the highest end models but the PIC32MX(360|460)F512L has 512 K flash, 32 K RAM and comes in a 100 pin TQFP package. They’re really fast, powerful, energy efficient and you can do pretty much anything with them.
    • Since they come in a 100 pin TQFP package, they may be a bit hard to solder and do not fit on breadboards, so I recommend getting a 100 pin TQFP adapter from Futurlec, or even purchasing a UBW32 development board.
    • Go for the highest end chips, the PIC32MX360F512L for the regular and the PIC32MXF460F512L for the model with an onboard USB module.

All in all, the 16F886 and 18F2620 are two cool chips that any hobbyist should have.

Oh, and don’t forget the PICKIT2.

Wednesday, March 18, 2009

Rorschach’s Quotes (from Watchmen [2009])

(In Rorschach's Journal) Dog carcass in alley this morning, tire tread on burst stomach. This city is afraid of me. I have seen its true face. The streets are extended gutters and the gutters are full of blood and when the drains finally scab over, all the vermin will drown. The accumulated filth of all their sex and murder will foam up about their waists and all the whores and politicians will look up and shout "Save us!"... and I'll look down and whisper "No." They had a choice, all of them. They could have followed in the footsteps of good men like my father or President Truman. Decent men who believed in a day's work for a day's pay. Instead they followed the droppings of lechers and communists and didn't realize that the trail led over a precipice until it was too late. Don't tell me they didn't have a choice. Now the whole world stands on the brink, staring down into bloody Hell, all those liberals and intellectuals and smooth-talkers... and all of a sudden nobody can think of anything to say.

None of you understand. I'm not trapped in here with you. You're trapped in here with me.

There’s probably more good ones. I’ll add them as I find them.

Thursday, March 12, 2009

Prototyping Wire

For breadboards, use thin, single-stranded copper wire. It bends and holds into various shapes and can easily pierce into the breadboard holes. However, for prototyping with copper strip boards such as Veroboards, stiff, single-stranded wire is not ideal. Instead, use thin, multi-stranded wire because it bends around stuff easily and does not get in the way. Also should be very easy to solder once you tin the tip of the wire. Be sure to twist the end of the wire when you strip it.

Tuesday, March 10, 2009

SPI Modes in CCS C

When interfacing SPI devices, the appropriate SPI mode should be used. The SPI modes are described here in detail:

Here are some easy to use defines for use with the CCS C compiler in the setup_spi() function:

#define SPI_MODE_0_0  (SPI_L_TO_H | SPI_XMIT_L_TO_H)    //SPI Mode 0
#define SPI_MODE_0_1  (SPI_L_TO_H)                      //SPI Mode 1
#define SPI_MODE_1_0  (SPI_H_TO_L)                      //SPI Mode 2
#define SPI_MODE_1_1  (SPI_H_TO_L | SPI_XMIT_L_TO_H)    //SPI Mode 3

Just put them in a header or source file somewhere and call setup_spi() like this:

setup_spi(SPI_MASTER | SPI_MODE_0_0 | SPI_CLK_DIV_4);

Note that SPI Mode 0 is a typical SPI mode. The AS1107 uses it, for example. I think it’s the most common SPI mode.

Sunday, March 8, 2009

My First CCS Program – 16F690 on Low Pin Count Demo Board (PICKIT2)

Here’s my first real CCS program. It’s for the 16F690 on the low pin count demo board that comes with the PICKIT2. All this program does is read the voltage on RA0 provided by the trimpot and show the 4 most significant bits of the result on the LEDs. Simple, elegant, easy and it works. CCS is really cool once you get it set up the way you like.




CCS Annoyance Update

Update: the progress popup window can be suppressed. Just go to Project Options > Output Files and you’ll see the option. You can even make it default for new projects. Source: Matt Pobursky from the PICLIST.

More About CCS C Compiler

  • When compiling a project, an annoying progress dialog pops up and stays for a few seconds after the compilation process has completed. Annoying.
  • CCS C compiler integrates well into MPLAB, so you can bypass the annoyance above. However, MPLAB does not come with the awesome project wizard, which brings us to our next point:
  • The project wizard doesn’t let you make modifications to your existing project. It only lets you create a new one.


I decided to reinstall ArchLinux on my 4 year old Dell Inspiron 6000 laptop today. For the record, the specs of my laptop are as follows:

  • CPU: Intel Pentium M 750 @ 1.86 GHz
  • RAM: 1 GB DDR2 dual channel
  • Screen: 15.4” 1680x1050 resolution

I decided to install a default ArchLinux install using the EXT4 filesystem. I kept most of the options default but installed a few extra packages such as GNU dev tools as well as wireless drivers. As far as partitioning is concerned, I used 4 partitions (/, /home, /boot, swap), all EXT4 except for SWAP. I installed from the 2009.2 USB images. The install completed very quickly – partly because I installed from a USB memory stick as opposed to a CD/FTP and because the filesystem was EXT4.

The installation completed successfully and I rebooted. I pulled out a stopwatch and started the timer just as I hit the enter button on the GRUB ArchLinux menu item. After exactly 10 seconds, I was fully booted into a BASH shell. EXT4 is extremely fast. My previous install took around 16 – 20 seconds to boot into a minimal BASH shell.

Can’t wait to setup a desktop environment and see how long it takes to get into it. In comparison, my windows XP (I’m dual-booting) boot time is around 25 seconds to get into the desktop. It takes at least 18 seconds to boot to the graphical login.

EXT4 is truly fast. Hopefully Ubuntu 9.04 will have EXT4 as an option. For those of you considering installing EXT4 – go for it. It’s fast, stable, and there are/will be a lot of useful tools for it including online defrag.

Friday, March 6, 2009

AS1107 LCD Driver Chip Interface Code for C18

I was unable to find any code to interface this chip on the Internet. However, there were a few people with videos demonstrating its use. After contacting them, borrowing a few of their driver ideas, and writing my own driver, I was finally able to get this chip to work. Here’s my driver.

  • Written for Microchip C18 compiler. Can easily be adapted to other compilers.
  • My chip is an 18F2620, however, the code can work with almost any PIC.

The code is pretty  much self-explanatory. The headers are where everything is defined and where the user is able to define pin assignments.


Thursday, March 5, 2009

DIY Automatic Precision Wire Cutter for Prototyping – Part 2

In the previous post, we examined a possible set of features and design goals for such a device. However, the feature set and design goals are difficult to implement. So here’s idea #2. The design is greatly simplified and has less feature. However, it should be much simpler to make.

The device will consist of a set of wire feed rollers, a wire cutter and a wire insulation stripper head. Since it is difficult to design a device that will fully remove the insulation off of the end of the wire, this design will not incorporate such a feature. Instead, this design will use the insulation stripper head to pinch (effectively cut) the insulation near the end where it should be stripped off. After it has pinched both sides, the cutting head will cut the wire. The wire will fall out and is almost ready for use. However, the insulation has not been stripped from the end; it has only been pinched. It is now very easy to remove the insulation by hand with your fingernail since it has already been cut. Here is a diagram of the design:



How it works:

  • Wire is fed into the wire feed rollers. The wire then goes into the thin tube in the middle which aligns the wire properly.
  • The wire is further rolled out until it reaches the insulation pinching head. At this point, a little more wire is pushed out (about 5 mm) so that the insulation can later be stripped off.
  • The cutting head then does its job by pinching the insulation so it can be pulled off easily by your fingernail.
  • More wire is fed. The amount that is fed is equal to the desired length of the wire.
  • Once the desired length of wire is fed, the insulation pinching head once again pinches the wire.
  • Now more wire is pushed so it can advance to the cutting head. The cutting head finally cuts the wire (end product) which then drops out of the machine.

This design is a lot simpler because it requires a lot less parts. Stepper motors and motor drivers can be found anywhere. The insulation pinching head can be acquired by dismantling a hand-operated wire cutter which can be found anywhere as well. The cutting head can be made out of anything – even cheap wire cutter pliers if desired.

The whole device can be controlled by direct connection to a computer or by a PIC microcontroller.

DIY Automatic Precision Wire Cutter for Prototyping - Part 1

One of the most annoying things while prototyping using solderless breadboards, prototyping boards, Veroboards and so on is cutting your wires at just the right length to make a perfectly straight connection. Sometimes, you may need a small piece of wire that will connect points 2, 3 or 4 holes across. If you have many of these, the wire cutting process itself will consume most of your time.

Well how about a DIY computer-controlled machine that will cut wire, strip it and bend the ends at a 90 degree angle for you at just the right length? Pretty neat, huh?

Design goals:

  • Inexpensive to build.
  • Easy to build.
  • Fast to build.
  • Easy to set up and use.
  • Compact and portable.
  • Can either be controlled by a microcontroller + LCD + keypad user interface for stand-alone use or can be controlled by direct connection to a computer.


  • User provides a continuous supply of wire to the machine.
  • User then selects the length of the wire and length of the contacts.
  • Machine cuts length of wire (= desired length + contacts length).
  • Machine then strips the ends of wire of insulation to expose the copper. This is done with respect to the desired contact length chosen by the user.

Already the design of the machine becomes quite complex. More details to come in the next post.

Monday, March 2, 2009

CCS C compiler is not as bad as I thought…

In the past, I had believed that the two best C compilers for PIC microcontrollers were made by HI-TECH and Microchip. I didn’t give much thought to CCS C as there are many other PIC C compilers in the market. I was pleasantly surprised when I gave CCS C a try.



  • Very easy to get started with and use.
  • Produces compact code.
  • Huge built in library of functions for peripherals and so on.
  • Large user-submitted forum code library and large user base.
  • Great support for many PIC devices from the low end 12 bit PICs (PIC10F) to the 14 bit PICs (PIC12F, PIC16F) to the high end PICs (PIC18F) to the DSPICs.
  • Powerful command line interface for the compiler.
  • Runs on Windows and Linux natively, (no need for WINE). However, the Linux version is lagging behind two updates (Linux: 4.085; Windows: 4.087).
  • MPLAB integration.
  • Well documented user manual – easy to read and understand.
  • Good support for data types, but could be improved (for example, by adding 64 bit data types).


  • Horrible, ugly, and otherwise inaccessible and intrusive user interface. Although beauty is in the eye of the beholder, I strongly believe that they could have made their IDE more pleasant to use by:
    • Using a standard widget set and not their horrible custom MS Office 2007 knock-off.
    • Making things easier to access by placing accessible buttons that perform common actions (open datasheet, open compiler manual, etc.)
  • Can be buggy sometimes and can be frustrating when you’re searching for a problem in your code and it’s actually the compiler’s fault. The CCS team needs to be a bit more careful with their updates.


All in all, the extensive code library and shallow learning curve make this compiler very suitable for hobby projects where you can actually spend time working on your project and not worrying about hunting down libraries or writing lengthy drivers.

DS12887 (DS1287) RTC Chip Driver Writtin in CCS C for PICs

Here’s a driver for the DS12887 (or DS1287) RTC chip written in CCS C for PIC microcontrollers. The code can easily be ported to C18 or HI-TECH C. Should be useful for my chip.

Dell Laptop CPU Frequency Scaling and Fan Control

SpeedswitchXP is a CPU frequency scaling utility for Windows XP which allows the user to select power profiles. I leave mine to dynamic when on both external power and when on battery. So far, it’s doing a great job keeping the laptop cool and quiet by reducing CPU speed when the processing power is not required (which is about 95% of the time). Now the fan never turn on high.

I8kfan is a fan control application that allows the user to set fan speed profiles. Make sure you don’t force your fan speed too low or the heat can damage components. I don’t use this currently as I let Windows manage my fan speed, but it’s a useful utility to have.