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.

Programming

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.

Debugging

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.

 

 

 

My First PCB

Circuit BoardsI have received my first printed circuit boards from OSH Park. They look great and I am looking forward to trying them out.

I have designed my own circuits, prototyped them on breadboards and soldered them onto protoboard before, but I really wanted to take the next step and produce a real PCB.

12V LED Dimmer

The PCB circuit is a dimmer control for a 12V LED lighting strip. It provides three means of control:

  1. Buttons on the device
  2. An IR remote control
  3. XBee from a computer

I thought I would make my first boards using through the hole components, but I would like to try surface mount next.

OSH Park ordering experience

These are double sided 2″ by 2″ boards and three boards cost me $19.95 including shipping. OSH Park charge $5 per square inch for three and you can order as many boards as you like, as long as they are in multiples of three.

I ordered the boards and received an email the same day indicating that they were awaiting panelization. OSH Park takes small orders, from Makers like you and me, and groups them together to fill an 18″ x 24″ PCB fabrication panel. When they fill up a panel they send the design file off to the fabricator to be manufactured.

Two days later I received another email telling me that the panel had been sent to the manufacture and they expected to get it back in four days. They even mentioned that there were 36 other orders on the panel and a total of 294 boards.

Three days later they told me that the panel had arrived back from the fabricator and that they expected them to be depanelled and shipped within 48 hours. The panel contains lots of boards connected together by little tabs with three small holes on each side. This enables the individual boards to be broken off the panel. If you look at the picture of my boards you can see some of the tags still attached.

Seven minutes later I received an email telling me that my boards had been shipped. That email included a USPS tracking number.

Two days later a padded envelope containing the boards arrived at my house. So it took seven days from the date that I ordered the boards for them to arrive.

I think that’s pretty awesome price ($19.95) and turnaround time (7 days) for three custom PCBs. As a comparison if I ordered three 2″ x 2″ protoboards from SparkFun they would cost me $15.71 including economy shipping. And it’s nice getting frequent updates on where your board is in the process.

I have shared the board here on OSH Park.

Designing a board

I designed the board using an application called Eagle. CadSoft the company that make Eagle are generous enough to make a freeware version available which is very popular with Makers. You can download it from:

http://www.cadsoftusa.com/download-eagle/

The free version limits your schematic to a single sheet and your board size to 4″ x 3.2″, but that is more than good enough for most Makers.

Eagle takes a bit of getting used to as it is mode based: click to add a component and you’re stuck adding components to your board until you select a different mode from the toolbox on the left. But it’s worth investing in learning it as it opens up a whole new world of possibilities.

There are other circuit board design applications out there, but Eagle is one of the most popular. Also OSH Park will allow you to upload your Eagle files directly, which is nice for a first timer as it cuts out the step of generating Gerber files.

So now I need to find the time to solder some components to the board, with nearly one hundred holes on this board, it might take me a while!

Mini maker faire coming to a Barnes & Noble near you

Barnes & Noble Maker FaireMainstream retail meets the maker revolution.

So this is interesting news, Barnes & Noble are hosting a mini maker faire in every one of their 650 retail stores between Friday November 6th and Sunday November 8th 2015.

You can find out more from the announcement on their blog. The schedule is now available on the makerfaire.com site.

Maker Faires are family friendly show and tell events where Makers come to share what they have made and what they have learned. They take me back to the 1985 Alexandra Palace personal computer show where Clive Sinclair announced his C5 electric car.

The big Maker Faires in the Bay Area and New York drew 215,000 visitors last year and there were 119 mini Maker Faires last year. There is a mini Maker Faire in Seattle next week. But this is the first synchronized national event like this.

It will be interesting to see the maker movement meeting mainstream retail, if you are a maker spread the word and visit a local Barnes and Noble mini maker faire. You could even sign up as a presenter.

If you are interested in becoming a maker, take this opportunity to see what it is about at a local Barnes and Noble store.

Good fun and good business

This will be a fun event for the maker movement, but with magazine sales down and brick and mortar book sellers struggling to survive, this is serious business for Barnes & Noble.

Hosting in store events is an interesting strategy as it leverages their high street presence in a way that an online bookseller can’t replicate. And it gets people excited about a topic and open to buying books and kits from the store.

Personally I like the broad choice of books at Amazon.com and the instant gratification of downloading a book to my Kindle or an audio book to my Audible player. I am intrigued by the idea of a brick and mortar store offering something more social, but I wonder how that will translate to me spending more money at Barnes & Noble over the long term.

Becoming Maker

microchipAs a kid I was driven to understand how things worked. I deconstructed toys, unsoldered components from old car radios, disassembled and reassembled hifi stereo systems and learnt how to program High Street store VCRs.

My interest in electronics led to me doing a correspondence course where I built an oscilloscope from scratch. Then the microcomputer revolution came along and I was hooked, learning basic and Z80 assembly on a ZX80, and selling software in the computer magazine classifieds.

Back then computers were simple enough that you could know them inside out – you could buy a complete ROM disassembly in a book.

As my interest in computers led to a computer science degree and a software engineering career things got more complicated and things moved further and further away from those early tinkerer days. Operating Systems became huge, ecosystems became complicated and new development frameworks were being released every day. Now half of the software you use isn’t even running on the machine under your fingers, it is running in the cloud somewhere.

Then a second revolution came along, the maker revolution. Laser cutters, CNCs and 3D printers made it possible for individuals to convert digital designs into physical objects. Microcontrollers moved from being devices only accessible to embedded systems engineers to something school kids could program. And a community, supported by thousands of online how-to posts evolved.

Those microcontrollers filled me with nostalgia for the microcomputers of my youth, small simple devices that you could understand inside out. With their I/O headers and communication interfaces they begged to be connected to things, embedded in things, they begged to be used in new and creative ways. And they were small, so very, very small and ridiculously cheap – I could buy a microcontroller for less than a cup of coffee and hold one on the tip of my finger.

This was another revolution I had to join – I had to become a maker.