final project -- weekly assignments -- about me -- fab academy

Week 05: Electronics Design

Phase 0: Making Tools

I'm still working on getting KiCad into my normal, everyday workflow, so one step was to work on getting more components into its library. Ferdi had suggested making a complete KiCad Fablab Inventory two weeks ago, and I was a bit reluctant - I believe any new components should be complete, including 3D models and testing. I'm quick putting in a footprint, even making schematic symbols, but the toolchain for getting 3D models into KiCad is still a massive PITA. Now, Ferdi offered to do those as he has the toolchain up and running, and Daniel offered to throw in his own footprints and symbols, so we should get that thing done a lot better than I alone could hope to. A new project was born - The Fablab Inventory KiCad Library.

Phase 1: The "Hello World" Board

I had started doing the Hello World board during Week 03 to do some additional testing with KiCad. Also, Daniel and me had a rather mad idea to do something funny and push the little ATtiny to (or, most likely, way over) its limits. That idea changed a bit when we found out that we can use other microcontrollers, too. After playing around with them, I don't particularly like AVRs, and the "imported" electronics I want to use for my final project are PIC based. So, the mad idea moved on to a different platform, leaving the schematic of the Hello World board orphaned:

schematic of the hello world board

It couldn't stay that way, of course, so I completed it with the minimum the assignment said: A button (or two) and an LED (or two), and threw together a layout:

the hello world board

It runs Neil's demo software, so... going on to the fun part. I dropped the project files here on the way in case anyone is interested.

Phase 2: The Fabboy

The Idea

The utterly mad idea two weeks ago had been to not only add one LED to the board, but a whole lot of them - a small and cheap OLED display. And a few buttons. And software for a game, like a primitive version of Tetris. My "everyday" 8 Bit PIC is a bit faster than the original Gameboy, but only has half the memory (roughly 4 kB). That should work out for Tetris, and it should work out for Cat Invaders, both of which are available in a heap of open source projects. Porting one of those to the PIC can't be that bad, can it? (Yes, it can. But I don't care!) Embedded Programming will be another assignment...

From Zero To Schematic

Schematics don't grow from thin air, so the first step was to create one. As this project will be a rather simplistic "some stuff around a microcontroller"-project I started off by collecting what stuff I wanted to have and where it should be connected:

The buttons were the first thing to be fixed in the end, as with six buttons and six pins-with-pullups left, they were an easy fit (and less layout work). With RB1 / RB2 used for buttons, the I2C for the display ends up on RC3 / RC4, and only a few PWM pins remain free. I used RC2, so the schematic is more or less sorted:

schematic mostly done

There's a power-LED already added, which might help when debugging this thing. And brings up the next problem: How do I power my toy? A battery might be cool, but adding a rechargeable one and not killing it adds to complexity and workload, I'll leave that out for now. I could plug a power cable into the debugging port, but that blocks out any other use of this port - like multiplayer. So, again, no. In the end, I added a micro USB port, not doing any USB, but just drawing the few milliamps of power I need. It's not OK with the standard, but it should work.

schematic done

There is not much more to this schematic. The I2C needed its pullups, and I put some capacitors to the PIC's as well as the display's power supply. And that's it. With 5V from USB, our power supply is set and the PIC doesn't really need a crystal, so I'm leaving that out.

Drawing Up The Board

For a lot of simple games like Tetris, a landscape screen is a rather stupid idea, especially one as wide as the small OLEDs we have. So, I decided to put it in as a portrait display, which looks odd, but should work. Also, with a display that small the whole thing shouldn't really be big. At the same time, I really like the general layout of the original Game Boy Advance, so I shamelessly copied it (it wasn't new for Nintendo, either...). The "ambience" LEDs ended up around the display.

With the display dead center on the board and buttons on both sides of it there is little place left for the microcontroller - It could either go on the backside, or below the display. I put it on the backside, in the middle... so the I2C connections get really short. It's not really important, though.

Next, I moved around parts trying to get the connections as un-chaotic as possible. Since I don't care (yet) about which button ends up being which function, they are ordered (on the board) by their connections. It's six identical buttons, first time I start caring about which one is which is when writing the software for them.

Then, I drew an outline for the board - Just so it looks cool, there will be a lot of empty space on this one. With the board edges defined, I placed the USB and debug connectors, then sprinkled the board with the few capacitors and resistors it needs.

The finished layout

To be able to mill it, I had to adhere to some design rules, of course - Most of which are more or less taken from experience with the PCB mill. I set the values in KiCad to a minimal track width of 0.25mm, with a clearence of (also) 0.25mm. Both values are conservative to what the mill can do when taken to its limits, as I had no intention of driving stuff to its limits (and having to deal with failures). KiCad will automatically make you adhere to the rules you set during routing, so usually things will turn out OK. It's sensible to also run a complete DRC before finally milling the board, of course, to catch any stray problems:

DRC finished, no errors found

The six unconnected nets it found are acceptable in this special case, as they are at the buttons, which don't really need the missing connections. So, while they can't be ignored by default, I ignored them in this case, and made the board.

The design files are available, of course. I made the board, and did a first bit of software for this board during Datasheet reading week.

If you want to build your own, you will need:

ReferenceAmountType
IC11PIC18F26K22-I/SO
DS110.96" OLED Display
SP11Speaker PKM13EPYH4002-B0
P11SMD Pinheader 6-pin horizontal
P21Micro-USB jack, ZX62D-B-5PA8
SW1, SW2, SW3,
SW4, SW5, SW6
6Tactile Switch MC32882
D7, D8, D93Green 0603 LED
D1, D2, D3,
D4, D5, D6
6Red 0603 LED
R1, R2, R3, R64Resistor 0603 680Ω
R41Resistor 0603 18Ω
R51Resistor 0603 2.2kΩ
R7, R82Resistor 0603 4.7kΩ
C1, C3, C53Ceramic Capacitor 0603 1µF
C21Ceramic Capacitor 0603 10µF
C4, C62Ceramic Capacitor 0603 100nF

final project -- weekly assignments -- about me -- fab academy

Creative Commons License
This work by Christoph Nieß is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.