Thursday, September 3, 2009

Electronics Hobbyist Checklist

Time to document some of the mistakes I have made more than once so I won't ever do them again:

  • Mirror the BOTTOM layer of the PCBs before milling them! I just finished a perfectly milled double-sided board. Too bad I forgot to mirror the bottom of the board (and did mirror the top of the board). Unfortunately now all its good for is a reminder not to do that again. From now on, I'm putting some text on the top and bottom of the board layout so I'll always know that the board is mirrored correctly before milling.
  • Include the mounting holes in the board layout from the beginning so you don't have to move things later to accommodate them.
  • Don't route on the top layer to parts that you cannot solder on the top unless you have plated-thru holes. If you're milling the board, you don't have plated-thru holes.
  • Include test points on PCB designs where you need them. This is especially important when using surface mount components that you cannot clip a lead to. I use two .100 spaced holes and loop a spare lead through the holes to provide an easy place to clip a probe.
  • Include jumpers in power inputs where you might need to measure current. Not necessary if you include a power switch (or cheap power jumper header)
  • No matter how well you checked the solder joints and traces, use a current limiter on the power supply when you first connect the circuit. You MUST keep the magic smoke inside the devices or they will not work.
  • Surface mount components = easier layout, more compact boards, and less holes to drill. It takes a little more practice and patience to solder them, but they really do have some benefits to hobbyists too.
  • If possible, use a diode on the power input for polarity protection.

Tuesday, April 14, 2009

Electronics Calculator Released

This is not the usual post. Instead of hardware or even firmware, this one is about some electronics related software I recently wrote for my Nokia N810 Internet Tablet.

The N810 is a small touchscreen computer that runs a version of debian linux called Maemo. The hardware itself is very capable, and since I bought mine it has never left my side.

I immediately started using it for many electronic related tasks. I stored my PDF library of datasheets on the device where it is easy to look up a component without leaving the workbench or dragging over a laptop. If I don't already have the datasheet, I fire up the browser and go look it up. No need to write down the part number and walk over to a computer - I just look it up right there.

I also use a fantastic application called Xournal to make quick notes and drawings with the stylus. It is wonderful for quick schematic sketches ( that can later be exported as PDF files ).

I also found myself reaching for the N810 when I needed to do a calculation, but found the available calculators to be clunky for that purpose. I soon started using the many available javascript electronics specific calculators, but that was just a little too slow, and I usually thought there was a better way to do them.

Thus I started to create the Electronics Calculator for Maemo. I wrote it in Python because it is a very nice language that runs well on the N810, and it is considerably easier to develop and test in Python than in a traditional compiled langauge like C or C++. Java does run on the N810 (beta), but it is too resource intensive for me. It does have some major memory limits. Of course, I also wanted to learn Python. Gotta say I like it, but I digress.

The Electronics Calculator installs on the device and runs blazing fast. It is always there for a quick calculation or to figure out which resistor value I have on my prototype board.

Currently the calculator has tabs to calculate:

  • Ohms Law calculations: Enter any two of Voltage, Current, Resistance, or Power, and calculate the other two.
  • Capacitive Reactance calculations: Enter any two of Capacitance, Frequency, or Reactance, and calulate the other
  • Resistor Codes: Select the color bands, Enter the three or four digit SMT resistor code, or the resistance value, and calculate all the rest.
  • Capacitor Codes: Enter a capacitance value or 3 digit SMT code and calculate the other.

For details, see:

Oh yeah - its written in Python with the pygtk toolkit, so it will actually run on any platform that has Python, Pygtk, and the GTK+ toolkit. I actually build and test it in Windows. Its not easy to get all the pieces for the environment together, so I am going to see if i can use the py2exe tool to create a windows distribution for all you poor suckers that have not bought one of these excellent devices to run it on.

If you are using Linux, just go to the source repository and grab the current file. You probably already have Python and GTK+ installed, so you can just make that one file exceutable and run it.

Sunday, February 1, 2009

Swimming Event and Heat Display

Both of my children are on a summer swim team, so it is pretty normal for me to be at a swim meet a couple of nights a week in the summer. Last summer, while I was at a meet at Pusch Ridge, I noticed a large LED display that showed the current event. That was pretty handy since most of the swim meet involves talking to friends, only to stand up to watch your children swim. That usually involves at paying attention to the current event and the announcer. At this particular meet, I was able to tell what event it was by just glancing at the sign. Naturally I said "I can build that!" and proceeded to start on a design

The one at the Pusch Ridge meet had two digits for showing the event number only. I figured the heat number would also be nice, so I added that to come up with a three digit display, with a permanently lit dash between event (2 digits) and heat (1 digit). I also decided it would be nice to clearly show a "Event" and "Heat" heading above the appropriate digits.

The fact that the display would have be hung around a pool, and thus water, led to the conclusion that it should be battery powered to avoid a shock hazard for the children. A quick calculation of the current draw of five high brightness LED's per segment for three 7 segment digits indicated that those batteries had better be rechargable.

The display may be exposed to the weather (summer is monsoon season in Tucson) meant I wanted a sealed case. The fact that I am a cheapskate led to building the case myself.

I started the design by digging through my junk pile to see what I had to build it with. The first thing I found was some 4511 BCD to seven segment LED driver ICs that I bought before I discovered the wonders of microcontrollers. This seemed like a great time to get rid of those. With three of those, I could forget about segment tables and multiplexing and get a nice bright display while driving them with simple BCD values that would make the microcontroller program a piece of cake.

I also found a PIC16F688, which seemed to have about the right amount of I/O to drive the BCD values and the latch enables on the 4511 with enough left over to allow external control.

I did not have anywhere near enough LED's for the project, which led me to search various suppliers for great deals. I needed 105 LEDs just for the digits (5 per segment x 7 segments x 3 digits), plus more for the backlight on the titles and the dash, so quantity discount didn't seem to be an issue.

After searching all the usual suppliers and googling cheap LED, I finally ended up on EBay where I got 200 5mm water clear high brightness LEDs for $7.98, including S&H (from China).

I also needed to drive my five series LEDs per segment with the raw power supply (nominally 12v) instead of the 5v Vdd that the 4511 and PIC chips got, so each segment required a transistor driver. I choose the 2N4401 because that is what I had the most of lying around, and its specs (Vce=40v and Ic=600ma) are more than enough to handle the job. I bought more from another supplier on EBay (this one in Florida) so I would not run out.

After toying with the idea of serial control or a wifi or bluetooth transciever (and comparing the relative costs of each), I decided on a IR or RF remote control. A bit more searching in the usual places and I was back on EBay bidding on a 4 channel RF receiver module and remote control ($6.60 + 5.00 S&H).

That gave me all I needed to put it together.


First I used FreePCB to layout the drill and mill pattern for the front panel. I then used my PCB Milling machine to drill the 5mm holes to mount the LEDs and to cut the outline of the letters "Event" and "Heat" to be backlit. I used FreePCB because it produces files that I could easily use to mill and drill a piece of 1/8" hardboard. In retrospect, it probably would have been easier to print the layout, tape it to the board and drill and mill manually with a hand drill and dremel tool. After cutting it out, I painted the front side of the board flat black, then epoxied the LEDs in place on the back of board. I bent the LED leads so that each segment naturally formed a series connection, which I later soldered together.

Next, I again used FreePCB to layout the PCB for the driver circuitry. The layout needed to fit within the available space inside the digits on the back of the display board - that determined the size of the board and the number of boards to use. Given that I needed at least two resistors per segment (one to control the current through the LEDs, and another to set the base current for each of the 2N4401 transistors), that meant 42 resistors. To put it another way, using surface mount components for the resistors would save a lot of board space and mean drilling 84 less holes. Seemed like a no brainer to make this my first board to use surface mount components.

I found that I still needed to break the logic onto two double sided boards to make it all fit. I put two digits (the event driver) on the first 3.25" x 3.25" board with the two 4511 latching seven segment drivers, and the associated transistor drivers. The other board (3.25" x 2.6") contains one digit driver, the microcontroller, the voltage regulator for Vdd, and the connector for the RF receiver module.

Each segment has the same circuitry -- a base current limiting resistor that drives the base of the 2N4401 transistor. The emitter of each transistor is grounded, and the collector is connected to the cathode side of a series of LEDs (5) via a series resistor. The anode side of each LED string connects directly to the positive side of the power supply.

An 8 pin SIP header on each board is used as a bus to relay the control signals between the processor and the drivers. The header contains the four BCD inputs, the two latch enable inputs for the 4511's on board 1, Vdd, and ground.

The bottom side of each board is primarily a ground plane (made a lot of sense because of all the grounded leads on the transistor drivers), with a few "jumpers" to route signals that could not otherwise be placed on the top layer.

I used 24 ga phone wire to connect all the appropriate LED segments to the driver boards (thats all the colorful wire in the photos). By using wire from a 25 pair cable, I was able to color code all of the segments so it was not necessary to trace as many wires while debugging the circuit.

The center dash, and the backlight behind the "Event" and "Heat" headings is hardwired to series current limiting resistors on the driver boards. They are not switched.

I built the case out of 1/4" MDF board, then painted it black and sealed it with several coats of outdoor urethane.

The display panel will screw into an inset in the case, then, when it is all put together and tested with its power supply and charger circuitry, I will use waterproof silcone sealant to glue on a clear plexiglass panel in front of the display panel. That should leave a completely sealed self-contained unit with only a single power connector penetrating the case (on the bottom where gravity will work against any leaks if it rains).

I wrote the software in PIC Assembly. It is pretty simple, detecting the four input channels from the RF unit to control event up, event down, heat up, and heat down. The seven segment latches are loaded with the BCD form of the new value by asserting the shared BCD digit bus and setting the appropriate latch enable for the 4511 chip.

The power supply will be based on rechargable NIMH AA batteries (10 * 1.2 volts = 12V). The batteries used are 2600 maH that should give at least 5 hours of run time at maximum draw. A charger circuit will be built into the battery charger.

To simplify the need to align the double sided boards on my milling machine, I laid out both of the boards at one time, and used the extra 1/2 X 6" space to layout a logic probe circuit (to be described in a later post)

The battery charger/power supply will be described in a later post. I'm in the final testing stages of the prototype design for that now.

From Vince's Electronics Blog