Monday, May 28, 2018

Building the Nestronic Prototype (Part 3)

(For background, please read the [Introduction] and [Architecture] blog posts.

Introduction

I eventually got to the point where the schematic was mostly finalized and the whole thing was working on a breadboard. While a big achievement in and of itself, it was far from a finished product.

First, breadboards usually look kinda messy. After all, they tend to evolve as you tinker with the circuit design. Also, breadboard wires are never the exact right length for any given connection. While you can make a clean-looking breadboard, it often requires far more time and effort than one is willing to put in for a simple prototype.

Second, breadboard connections are a little flaky. Breathing on your circuit the wrong way can cause this wire or that resistor to have just enough of a contact issue that something starts or stops working reliably.

Third, breadboards are noisy and full of stray capacitance. I could detect clock signals from one end to the other. Digital connections sometimes had just enough noise to make the difference between a high and a low. And to quote Dave Jones, you sometimes have to "hold your tongue at the right angle" to get things to even start up correctly.

Breadboard Nestronic
At this point I exported the netlist for my schematic, pulled it into KiCad's PCB tool, and began the layout and routing process. After a lot of work, I eventually ended up with a complete board design. The core of this layout was the NES CPU section, with all its parallel bus traces. The rest was kinda squeezed in around it. Perhaps not the most optimal of layouts, but good for the general size and shape of the enclosure I wanted to put it in.

PCB Layout



Reflow Soldering

As I finalized the schematic and began to work on the PCB layout, I knew I was going to need a solution for reflow soldering. The hot air gun I used for assembling prototype breakout boards just didn't feel up to the task of doing a complete PCB. During my initial research, it seemed like there were a few options out there:
  • DIY with a toaster oven and control electronics
  • Hot plate, with some careful timing and positioning
  • $200-400 IR reflow oven from some random Chinese OEM, which might require a complete DIY rebuild for acceptable performance, and which might unevenly bake and/or burn my boards from time to time
  • $3500+ convection reflow oven, possibly needing a 220V power plug and a lot of space

I wanted to focus on my project, not my tools, so I had a strong motivation to avoid DIY here. Initially this severely limited my options, since there really weren't any good off-the-shelf choices. That is, until I discovered the ReflowR and the Whizoo Controleo3.

Originally I went ahead and ordered the ReflowR, which is a temperature profile controlled hot plate. However, it took so long to ship that I gave up waiting and went for the Controleo3 instead. (While the Controleo3 is sold as a conversion kit, I decided to spend more and save time and simply bought the already converted oven.)


Whizoo Controleo3 Reflow Oven
While waiting for the Controleo3 to arrive, I decided I wanted to do a complete workflow test. After all, if I was going to put all this effort into a complex PCB, I might as well test the process on something simple. So over the course of one evening, I designed a small board to test some footprints from my main design. I ordered a PCB (from OSH Park) and a stencil (from OSH Stencils), and gave it a whirl.

Reflow Test (microSD Breakout Board)
The most important parts of this board were testing a custom-made UFDFN footprint, and reflow soldering of a microSD card slot. The UFDFN footprint was of special interest to me because I couldn't find a good breakout board to test the chip sitting on top of it. I instead had to find a "sorta close enough" one on Tindie, which was very difficult to actually get working.

In any case, the test was a complete success! So, it was time to move onto the real board.

Preparing for Assembly

With the success of my reflow soldering test, I went ahead and ordered the real PCB from OSH Park, the solder stencil from OSH Stencils, and all the remaining parts from Digi-Key. It was a long night due to the large list of components, and because stock issues caused me to need to select replacements for a few of the jellybean parts.

Since assembling the board was going to be a big project, and I had a vacation coming up, I decided to go with the "slow" option on OSH Park to force me to wait until after the vacation to begin assembly.

During the week preceding the vacation, all the Digi-Key parts arrived. I then printed out my BOM (bill-of-materials) and started organizing everything. Eventually I had all the parts accounted for, and bagged by category:

Components Labeled and Organized

Meanwhile, my OSH Stencils order (which shipped within a day of placing it) still hadn't arrived. The USPS tracking info was confusing, and I was starting to wonder if they had lost it. My trip was getting close, so I was starting to get worried. Eventually, after apparently taking a week-long scenic tour of San Francisco, it arrived!
Stencil's Scenic Tour

Assembly Time!

I returned from my vacation to find an OSH Park envelope waiting for me in the pile of mail. My ready-to-assemble PCB was here!

Nestronic Main PCB

After spending maybe a day or two recovering from the vacation, I went into my garage lab and got everything ready to go. I had the PCB secure in a jig, the stencil and solder paste handy, and a microscope to make sure I could accurately pick and place all the parts.

Ready for assembly
Stencil aligned and ready for pasting

At this point, I squirted out a generous amount of solder paste and smeared it across the stencil. When I finished, I carefully lifted off the stencil to reveal a perfectly pasted board.

Paste application complete

I then spent the next two hours (at least) carefully placing all the surface-mount components under a microscope, using a pair of tweezers.

As I neared completion, I found my first two issues with the design. The first issue was that the footprint for U7 (SRAM chip) was a bit narrow. Thankfully it was close enough, so I took note and just dropped the chip on there anyways.

The second issue was a bit more serious. Apparently, I designed the PCB assuming U11 (PCA9564 I2C controller) had an SOIC footprint. Meanwhile, the parts in my inventory used a TSSOP footprint. To make matters worse, the SOIC version of the chip has apparently been discontinued. Fortunately, Mouser still had some in-stock. So I decided to forge ahead without the chip, place a frantic overnight order, and rework it into the PCB another day. After all, you can't really just let a pasted and partially populated PCB sit on the table for that long.

Almost all components placed
I finally put the board into the reflow oven, hoped for the best, and tapped "Start."

Ready to Bake!

After baking, I did an initial inspection of the board. There were a few components with solder bridges I needed to clean up, which took a few minutes with a piece of solder wick and a soldering iron. I then hand-soldered most of the remaining thru-hole components, and soon after was ready for first power-up!


Assembly mostly complete


Initial testing

For the first test, I connected my USB-to-serial adapter to the board. I then applied power and saw the first console messages coming off of it! It was working, or so I thought...

First serial connection

Not long after, I started to smell something suspicious and immediately powered off the board. I began carefully probing and prodding it, and quickly noticed a few things. There was unusually high current draw, and I was reading about 60 ohms (give or take) between the 3.3V supply rail and ground. Oh no, did I have a short somewhere?

At this point, I tried everything. I scrubbed the whole board with alcohol, inspected every inch of it under the microscope, and cleaned up anything that even resembled a potential bit of excess solder where it shouldn't have been. No matter what I did, however, the short was still there. I tried to locate it by comparing the nth digit of the 3.3V-to-ground resistance measurement at different parts of the board, but wasn't having a lot of luck.

Eventually, after letting it sit overnight, I tried a thermal test. With the board powered up (on a current-limited supply), I felt all the components with my finger. Eventually I found that U8 (MCP40D17 I2C rheostat) was getting warm. I desoldered it with my hot air gun, and the problem vanished. Apparently, something I did had caused this component to develop a short. A quick check of the schematic and the component's datasheet gave me a quick clue:

MCP40D17 Connection Schematic


MCP40D17 Maximum Ratings
I was powering this chip off my 3.3V rail, and controlling it using a 3.3V I2C bus. Its resistor pins were being used to control the gain on an audio amplifier, which itself was on the 5V rail. During breadboard testing I never saw more than 2V across these pins, so I didn't think much of it. However, without the RP2A03 CPU installed, the voltage apparently shot up to the full 5V. This was way out of spec, and destroyed the chip.

Thankfully the fix turned out to be a simple bodge where I cut a trace and moved the chip's power pin over to the 5V supply:
U8 power fix

The next issue surfaced when I tried actually using the ESP tools (i.e. "esptool.py") to interface with, and download code onto, the ESP32. I designed my board to include the common transistor bootstrap circuit which allows the DTR/RTS pins on a USB serial adapter to put the ESP32 into flash download mode. This is a huge convenience feature for development, and common on ESP32 breakout boards.

For some reason, however, this circuit wasn't working on my board. I probed every part of the circuit, manually stimulated its inputs, and even tried changing out some of its input resistors. Not only was it not working correctly, it was behaving strangely.

ESP32  Bootstrap Circuit

After hours of complete confusion, I eventually decided to take a final look at the datasheet for the S8050 transistors. I then compared it against my schematic and KiCad's SOT-23 footprint. After a few rounds of this, the issue became clear:

Transistor Footprint Comparison

Apparently the transistor symbol combined with the SOT-23 footprint used a different pin assignment from my transistors! This was hard to catch, because the transistor's datasheet didn't actually number the SOT-23 pins. Thankfully, this one had a relatively easy kludge. I just had to re-solder the three transistors upside-down, and then their pins would be going to the right places.

Transistors Resoldered Upside-down
Finally, bootstrapping was working correctly. So, I got the board ready for its first real test.

Its Alive!


PCB Fully Assembled
At this point I loaded my latest firmware, installed the board into the bottom shell of my 3D printed enclosure, and viola!



Path Forward

On top of everything discussed here, I found a few more issues as I put more of the pieces together:
  • The test point I reserved for ADC calibration was on a pin with pull-up resistors, and thus couldn't actually be used for that purpose
  • The ambient light sensor couldn't usefully detect light through the front of the case, and would need to be replaced with a different sensor on the top of the case
  • My memory map couldn't support the address ranges used by the NES APU's DMC output, which a handful of games apparently use
I'm almost definitely going to be doing a Revision B of this board before the project is finished, but things are in a pretty good state for now.

The next major step is the design and assembly of the input board. Until I have that, there's really no good way to actually control this device at run-time. I designed the input board connector pin-out from this board to expose an I2C bus and a few support pins, so I'll have plenty of flexibility there.

No comments: