PCB populated and tested

Populated PCBI found some time last week to populate my OshPark board and test it. You can see it here connected to 12V power (bottom) and a 12V LED strip load (top).

Soldering the through the hole components didn’t take too long. I didn’t have any problem with the connections where I had omitted thermal relief, but they did take a little longer to heat up.


Thermal relief

If a component is connected directly to a large area of copper on a PCB such as a ground plane, the copper will conduct the heat away from the soldering iron making it more difficult to get everything hot enough to solder.

thermalreliefA thermal relief reduces this effect by adding short traces between the connection point and the copper area as shown in this illustration from Eagle.

I omitted the thermal relief on the 12V power connections to ensure the traces could carry plenty of current without heating up.

Having large traces and direct ground plane connections for the high current part of the circuit is necessary as thin traces will heat up if too much current is passed through them, wider traces can carry more current.

My LED strip is only drawing 1.25A, so this might be overkill as I only need 16.5 mil of trace to carry a 1.25A load with a 10 degrees centigrade temperature rise. But it seemed like a good idea to design in some extra current carrying capacity.

The MOSFET I used can switch 16A, but in its TO-220 package it already has a thermal rise of 6.84 degrees centigrade at 1.25A without a heat sink. So I would probably want to add a heat sink to switch more than 3A.


I tuned the adjustable DC/DC buck converter (green daughter board) to supply the board with a 5V and everything looked good electrically. So I inserted the XBee and the ATTiny85 microcontroller.

I attached a SparkFun ATTiny programmer to the board using a 6 pin ISP cable and uploaded my software to the ATTiny85.

The buttons worked as expected, but I was disappointed to discover that the IR and XBee serial input were not working correctly.


The SparkFun ATTiny programmer is a great $20 programmer, but it doesn’t provide any debugging functionality so I resorted to the age old technique of modifying the code and flashing an LED to indicate what was going on.

I took the time to fix a bug, which I already knew about, that would cause the IR input to malfunction if a serial input occurred at the same time, but things were still not working correctly. When using interrupts you have to think carefully about what would happen if an interrupt triggered at an inopportune moment.

Then I noticed that the serial input was low when it should have be high. The XBee serial out should always be high unless it is sending data to the ATTiny85. When I checked the XBee serial output was indeed high, but the signal wasn’t triggering a high on the ATTiny digital input.

In Circuit Programmers

An ATTiny85 only has eight pins, for power, programming, and input/output. Programming the ATTiny requires six pins: GND, 5V, Reset, SCK, MOSI and MISO. My circuit requires 7 pins: GND, 5V, Up Button, Down Button, Serial input, IR input, PWM output. To accommodate these eleven different functions on 8 pins requires that the programming and I/O functions share the same pins.

For the programmer to work effectively while the ATTiny is in-circuit it is important that the circuit doesn’t interfere with the programmer. For things like buttons, this isn’t a huge problem – use large value pull-up resistors and don’t press a button in the middle of programming, but for the serial input pin this is a problem as the line is being held high even when there is no serial activity.

So I put a 1K resistor between the XBee serial output and the ATTiny85 serial input so it would not interfere with use of the pin as MOSI during programming. The XBee voltage is only 3.3V, but the trigger voltage of the ATTiny85 is 2.5V (with 5V power) so it can still trigger a high digital input. Adding the resistor directly between the XBee serial output and the ATTiny85 input doesn’t cause any noticeable voltage drop, so this approach works well.

Blinking LEDs

However, the SparkFun ATTiny programmer has a yellow LED connected to this same pin via a 330 ohm resistor. This is nice as you have an LED you can blink for testing and debugging on pin 0. Pin 0 can be a digital output in addition to a serial input and MOSI.

However this feature of the programmer caused the voltage to the ATTiny serial input to be dropped too low as the 330 ohm resistor and the 1K resistor act as a voltage divider with the ATTiny serial input pin in the middle.

Voltage Divider Calculation With An LED

The addition of the LED makes the voltage divider calculation a little more interesting. The voltage divider needs to be applied to the voltage between 3.3V and the LED, which means we must subtract the voltage drop of the LED first.

The yellow LED will drop the voltage by its forward voltage. Yellow LEDs are quoted as having a forward voltage of 2.1V, but that is at their brightest – it is a useful value to calculate the value of a resistor that will not cause the LED to burn out. However, with the 1K and 330 ohm resistors between the LED and 3.3V the LED is only drawing 1 to 2 mA of current and will only drop the voltage by about 1.7V. The datasheet show a graph of forward voltage by current.

So the voltage divider needs to be applied to 3.3V – 1.7V = 1.6V. The voltage divider equation is Vout = Vin*R2/(R2+R1). Where R2 is 330 ohms and R1 is 1K. See Wikipedia for details.

Vout = 1.6 * 330/(1000+330) = 0.4 V

Then we just add back the forward voltage of the LED to get the full voltage for that point in the circuit.

1.7 + 0.4 = 2.1 V

Which is below the 2.5V trigger threshold of the ATTiny85. So the ATTiny85 reads this as a digital low.

The Fix

As far as my code was concerned the serial input was continuously setting a zero dimming level. The simple fix was to unplug the programmer, upon which everything started working perfectly!

A workaround for testing the circuit with the programmer attached is to use a strong enough pull up resistor to push the serial input over 2.5V. I chose to add a 1K pull up resister between MOSI and 5V on the programmer which will add 0.6V. This is a similar voltage divider to above, but with a 5V input rather than a 3.3V input. I attached this to the header pins on the programmer, but I don’t want to make this a permanent addition to my PCB as 1K is rather a strong pull up which would draw unnecessary quiescent current when the programmer isn’t attached.


The next step is to design and 3D print an enclosure.