Sunday 16 August 2015

Learning-by-doing: PCB design

As a mini project to learn about hardware design/electronics I thought it would be fun to build some new insides for something. I found a collection of three 'untested' Nokia 6500 slide phones on ebay for a few quid which looked perfect. I intentionally did not do much planning, because it's boring, and there's more to learn by making mistakes if you're willing to accept some failure. Having said that, my basic plan was to make something simple with a microcontroller and common parts, and get it working to learn the process and make some newbie mistakes; then afterwards, make something a bit more complicated (higher density board, BGA, etc) and maybe even useful.

I've only recently discovered that nobody etches their own PCBs at home anymore, because there are overseas companies like Elecrow that can offer this service with professional quality results for a very low price by combining lots of different customers' boards on one panel. They offer a very cheap special offer for 10 identical small PCBs with 6/6 space/trace and 12mil vias. The premium service goes down to 3/3 and 8 but is based on individual quotations.

Common sense says this should have been a 4 layer board, but:4 layer boards are much more expensive than 2 layer. This also had to be 0.8mm to match the original and fit in the phone (even 1.0mm would be too thick, I checked), which added $18 to the price. When you're already paying that much you might as well get it with an ENIG finish as well because it looks nicer... and adds another $18 :/ Also the freeware version of Eagle only supports 2 layers. So for a future version, OK maybe... but for this first prototype that might not have even fit in the case or something, I stuck with 2 layers (scroll down to see the results!). I also didn't push their limits and most of it is 8/8. Some places might be 7 when it was necessary, I can't remember!

I best start off by saying I have no idea what I'm doing - I'm making it up as I go along to see what happens! I found a few mistakes before the boards even arrived (oops!) so a 'revision B' is already in the works. Some of my options were limited, and heavily affected the layout. I did not try and calculate the USB differential pair impedance as it breaks just about every other layout rule out of necessity, but it's only FS anyway so should be OK. Here's what other restrictions I can remember:
  • 10x5cm limit, 2 layer PCB (Actually was about 8.5x4.5 and had to be the exact same shape as the original)
  • Component heights <= 2mm
  • Some places with no components (battery area, and FPC area for the slide)
  • Positions of:
    • 50-pin LCD connector
    • 20-pin Keypad connector
    • USB connector
    • AV connector
    • DC connector**
    • Camera connector*
    • Battery 
    • Volume & camera switches
 * I ignored the camera for now - I don't have a datasheet but I know it's using one of the "top secret" MIPI serial standards and at a guess the MCU won't be fast enough to bit-bang this in any usable manner. Here's a photo I took of what I think is a logo & part code of some description from the image sensor die. I couldn't find anything else that stood out. It's a ~3MP sensor. Maybe I should hook up the I2C bus and see if it responds without any of the other connections...

** I have no use for the DC connector, so needed something to fill the 2.8mm hole. Apparently it's impossible to get a 2.8mm RGB LED, so instead I found these light pipes that work really well. Here's a torch shining through it backwards (not pushed in all the way because it would never come back out). The resulting problem was (assuming my maths worked out) the LED had to be 0.9mm in height from the PCB. PLCC RGB LEDs are nearly double that at 1.6mm. My solution was reverse-mounting the LED in a cut-out so I also had the 0.8mm board thickness to work with (i.e. 0.9+0.8-1.6 = 0.1mm wiggle room). Elecrow charge extra for castellations (it would have doubled the price!) so I made the hole a tiny bit too small and widened it myself.
The connectors were quite easy to identify. The 50-pin is a Molex 51338-0574, the keypad is a JST 20R-JANK-GSAN-TF. The usb and battery any cheap ebay version will do. If anyone knows what the 4 little V shaped springy contact things at the edges are called please let me know because I couldn't find anything even similar!

I remembered to take some screenshots along the way:

At this point I decided it was looking a bit unroutable so ripped it up and started again with the MCU at 45 degrees and moved down a bit:

Woo-hoo, finished! Ignore the "Rev. B" - I only remembered to take a screenshot after I sent the gerbers off and started fixing some of the mistakes (so there are a couple of minor changes):

Finished layout (no ground pour for clarity)
Finished layout (with ground pour)

So in 4 days Elecrow had made the boards and shipped them. They took only 8 days to arrive (China post):

They look great, I don't care even if they don't work :)

I didn't spot any flaws in the manufacturing (they're e-tested anyway) and I'm really happy with the results and service for the price. Where the low cost does show slightly is in the alignment of the silkscreen and soldermask. They're both out by about 4 or 5mil (the broken circle around TP18 was my fault - I forgot to change it and it didn't meet their minimum thickness) :

So how did I do with matching the original shape? Spot on actually, I was surprised!

And the first couple of idiot mistakes:

I didn't bother to check the datasheet/measurements for the JST header I picked for the debug interface. It overlapped the battery by a tiny amount so I had to shave a bit off:

I didn't notice this metal thing which bumps into the capacitor at the top of the board. It was that small of a change that it fit by soldering the cap not-quite-centered on the pads:

Aside from those, I didn't have any diodes that fit the footprint properly, but that wasn't really a mistake in the design I just didn't have the patience to buy some and wait.

EDIT: And I've just noticed I messed up the pad names for the volume switches so they're always pressed. D'oh!

Here's the finished rev. A board after soldering:

It passed a smoke test, and was detected OK:

...and it actually seems to work!

Now I need to develop the software/firmware and see if anything else is broken, then get to work on rev. B!