Beginner Home Assembly Episode 2: "H is for check your #$&^% BOM" - Page 1
Forum section: electronics / general

author: meshtron
author_rank: Regular Contributor
timestamp: October 22, 2023, 01:47:53 am
content: Second official entry in the ongoing mockumentary series of me cosplaying as a PCB Designer and Builder. Previousepisode heretalked through many of my reflow woes. Spoilers belowSo, having gotten 2 boards out of my oven (in a row!) that tested out perfect, I went ahead and finished assembly on one of them with 7 or 8 through-hole soldered parts. And, much to my delight, it took a flash right out of the gate!I have a lot more experience writing software and designing complex things than I do with PCBs and firmware, so I took a familiar approach here and divided testing my board/firmware into 7 independent "functions" which are more-or-less independent modules. I tested 5 with no (major) issues.One thing I learned here, which I'm sure I've read and is a newb mistake, is that for simple digital I/O switches (I have 8 dip switches that configure board behavior), it's important to pay attention to the pins you're tying to. I thought (for no good reason) my ATTiny48 had both pull-up and pull-down internal switches. But, it does not - it only has pull-up as clearly evidenced by the datasheet. I made a poor design decision - maybe usually poor - to switch +5V through my DIPs rather than switching to GND. I think switching to GND, even though I totally get it, still is a bit counterintuitive to me. Anyway, switching on +5v on GPIOs with no (when set as input) pull-down resistors means switching settings is not instantaneous.It seems like there's some internal capacitance on each GPIO, and when I switch off +5V (leaving it floating) it has to decay that capacitance through some high-resistance path to GND. So, low->high transitions are instantaneous (and a tad bouncy) but 1-0 transitions take a second or so. Not a big deal, but on the list to fix for next round.Other than that, no big concerns with the board which felt great.Then I came to module 6: validate SPI to slave device (DRV8144).Should be easy! Last version had working SPI between these parts, just retreading old ground here, right? Not really.I did discover some small tricks with ATTiny and SPI last time around, but I documented those for myself and blew right through them this time. But man, for the LIFE of me, I could not get data back out of the DRV8144 on MISO. No matter what I tried, MISO was never switching properly - just stuck high all the time. I spent a few hours last night and another few this morning reading datasheets, trying to find what could possibly be different between my current (broke) and previous (working) code, etc. I knew from last time that if I wasn't getting good message frames back, it wasn't getting my messages either and this chip requires you to wake it up by sending an SPI message. There is no workaround to "bypass" SPI with this chip.I was actually getting pretty frustrated. It's unusual for me - even on this journey - to beat my head on something for 6 hours and feel more confused than when I started. I got up, took a walk, and chatted with my wife. Now, my wife is a new character to this story. She is, to put it plainly, a saint. She's kind, funny, beautiful, happy, genuine, and in almost every way a better human than me. What she is not, by the stretchiest stretch of the imagination, is a "maker" or an "engineer" or a "technical person." She says to me "What if it's the chip?"Immediately I discount it. Reflow profile is DIALED, no way I smoked that chip. All the pins test good, no shorts, no surprises. Can't be the chip. And yet...Out to the garage to just see what there is to see with my lovely new 4K digital microscope. Check pins, check solder, looks amazing (to me anyway). Double-check all my connectivity stuff, everything is on point. Then I read the top of the chip. "DRV8144H"H you say? H. Wait, isn't there a hardware and an SPI version of this chip? Oh. Shit.Long and short of it is I had the right SPI part number literally everywhere EXCEPT my Digikey order. Since these chips are relatively pricey (about $5/ea) I only ordered 10, which I guess is helpful. I tried to make some changes to my firmware to make it work anyway, and it seems like it should (basically all the SPI pins just become diagnostic/cfg pins). And that is what sent me down a 5-hour rabbit hole on how compiler optimization works.On the ATTiny series (or at least on the 48/84), there are 3 registers that control the GPIOs. DDRX sets direction, PORTX sets a value, and PINX reads the value. If a pin is set as an output, the PINX register still shows the actual value on the pin. I had two critical control pins where, regardless of what I set for the control registers, they would stay high. A lot of going nowhere on this problem led me to start a from-scratch simple project to do nothing other than flip those bits (ruling out some hardware issue). And sure as shit - I could duplicate the bad behavior. Somehow I figured out that if I turned Optimization Off when compiling, suddenly the code worked as expected. I tested this every way I could think of to confirm I wasn't losing my mind but stumbled onto a discussion on avrfreaks about how compilers actually interact with code. The long and short of it was the compiler decided my code wasn't useful or interesting so just optimized it out. I did not take it personally.So, found the fix(es) for that and made those changes by setting some key "volatile" markers. Much to my shock and horror, THE SAME TWO PINS still stay high. But, I did some multimeter testing and realized they go legitimately to VCC when on, but they float to about 1/2 VCC when I set them low. I want to believe this is a different problem than the compiler stuff, but sure feels like I've misunderstood two different problems and am probably missing the 3rd real, root issue. In case it pops into your head, yeah I checked to make sure neither of the alternate functions of the pins in question are active.Somewhere around this point I decided it was time to call it a day for today. So, where I left it:- Board on my desk will take a flash, has wrong half-bridge controller chip installed- Two pins seem to be floating when they should be low, I have no idea why, but I think it's firmware induced- Most of the troubleshooting I'm doing now will get tossed in the trash once new chips arrive- Batch of 10 of the RIGHT chips ordered and will get here TuesdayI've got another 5 or 6 hours of time tomorrow to work, hopefully I can make a bit of actual progress. Have some 3D design stuff to do, I might swap to that for a while to feel less like I'm getting beat up at every turn.PS: I got two ofthese 4k digital microscopes from Aliexpress. Per other reviews, the cameras are amazing but all the hardware is junk. But, I'm going to set up a single-tower/2-boom floor stand that will move these off the table, excited to have much more work area under the scope!

author: asmi
author_rank: Super Contributor
timestamp: October 22, 2023, 06:14:53 am
content: Yeah, shit happened. Wrong part option number (when there are some options available for the part, but specific combination is pre-created by manufacturer and encoded into many letters-numbers after the "main" part number - Microchip loves doing that!), wrong package (QFN instead of DFN, SC-70 instead of SOT23, SOIC wide vs SOIC narrow, SMT buttons/connectors vs TH, etc.), wrong pin numbering on a footprint (this was a fresh one, just happened about a month ago), wrong pin names in a schematic symbol (again, fresh one), using schematic symbol from one package option with a footprint of another footprint option, and the list goes on and on.There is a reason schematic and PCB review is a thing in a commercial setting. That's because we typically don't smell our own sh*t, and can't see mistakes which would be obvious to anyoneexceptto a person who spent last few weeks actually making a design (which is us). I've been burned by this sooooo maaaanyyyy times that I came up with all kinds of rules and restrictions for myself in order to reduce the chance of such mistakes, yet pretty much all my rev A PCBs had some sort of flaw or fault in them caused by my inability to see clear errors in a plain sight, which always triggermoments when I discover them (typically after assembling the first prototype).But hey - at least now you've got a decent microscope, so now you can show your f ups in full 4K!

author: meshtron
author_rank: Regular Contributor
timestamp: October 22, 2023, 07:19:04 pm
content: Quote from: asmi on October 22, 2023, 06:14:53 amThere is a certain beauty in being able to see and share my minor catastrophes in high resolution.This will have been my 2nd BOM experience. It was definitely better than the first one (when I had PCBWay make boards and had wrong footprints, wrong part numbers, etc. which they graciously worked through). But, yeah - clearly still some holes to be filled as we go forward. The root of it, at least for how I'm thinking about it now, is much better library management in my eCAD tool (Fusion360). I'm a big believer in making sure the library is right (up to and including links to components on supplier sites) and letting that "single source of truth" drive me towards better outcomes. Still need to develop and adhere to a good review process - I bet my wife would be willing to help with that and she's always happy to find my errors.I also look forward to having enough of this under my belt that I can more quickly (and with some confidence) recognize what's likely to be a hardware or wiring problem vs a straight firmware issue. But, that's going to take some time I am certain!Bummed I can't seem to make the chip I do have work like I think it should, but I'm willing to admit defeat today and focus on some other aspects of the project and wait for new chips to show up. Maybe I can have a board assembly party as part of our Halloween party next weekend.

author: newto
author_rank: Regular Contributor
timestamp: October 23, 2023, 02:57:19 pm
content: Quote from: asmi on October 22, 2023, 06:14:53 amHere I sit, staring down at my prototype, with a SOT-23 voltage reference awkwardly sitting askew on top of an SC-70 footprint. Luckily I didn't pick SC-70 because I needed to spare that tiny amount of space, so it still fit okay with everything around it.Another thing to watch out for is when using a built-in library, double check that the pinout matches the footprint when there's multiple options when. Especially if you later decide to change the footprint to save space, and forget to swap the symbol for the other pinout...luckily had a compatible breakout board for that footprint that saved the day.

author: asmi
author_rank: Super Contributor
timestamp: October 23, 2023, 07:41:46 pm
content: Quote from: newto on October 23, 2023, 02:57:19 pmYeah, here is my "fix" for screwed up footprint of LVDS clock generator. I was lucky that output pins were shifted by 1 (because bodges are not gonna work for 200 MHz differential signal!), so I only needed to shift the part 1 pad, and add some bodges to connect pins which ended up hanging in the air (thank god the package has pins which go all the way to the side of a package).

author: meshtron
author_rank: Regular Contributor
timestamp: October 27, 2023, 12:32:05 am
content: In case my previous posts have left any doubt with respect to the depths of my ability to fail at even the simplest tasks, here's an update!I got the correct DRV8144Sparts in yesterday afternoon and after my day job, I wolfed down some leftover BBQ beans and rice (including this detail just so it's clear I was fully in the mode of making poor choices) and headed to the shop.First thing I did was inspect some bare boards and pick one that didn't have obvious solder mask missing under the TQFN part. Paste was quick and nice - one pass with paste clean and centered on all the pads.My assembly has 24 SMD components (a 7805, TQFN28 MCU, the DRV814X chip and all else 0603 passives) and 33 through-hole drills. Took me about 35 minutes start to finish including reflow, hand solder, cleanup, etc. I was very happy with that time and it's getting much easier to do the placement the more I do: the tedious part is still getting the parts out of their tape and into bins for placement - and I love the fact 0603 ceramic caps have zero markings on them. So, when they jump from one bin to the next, I either choose to ignore it or redo all of them! My TVM802B PnP will help with all that some day when it arrives, but that's a story for another episode.Reflow looked nice first try through but I need to make a tweak to my "custom" reflow profile on my T-937M because if I don't preheat it at all, it immediately ramps up, overshoots its mark, turns on the cooling fan, then never catches the initial heat to soak temp line again. The PID tuning is... Well it's not optimal. Pulled board, tested power, GND and output nets and found no problems. So, hand-soldered (something I'm getting better at, but still not good at) and was excited to come in and test! Plug it in to power, ground and my ATMEL ICE and...Nada. Can't read it. The ICE can see voltage (so I know I have things hooked up right) but SPI won't go. Head scratching, bit of cussing, some involuntary heavy sighing and internally questioning why I'm doing all this... Again. But, I do some poking around and sure enough, I find 3 pins on the MCU (3 of the same 4 that were a problem last time!) shorted together underneath the chip. Exterior solder looks great, not sure why, but there we are. So, I decide it's time to put my YouTUBE learnings to work. I add flux all around the chip, set my hot air gun to 360C, put the board under my (exceptional) 4k digital scope and start swirling the heat around watching for the little solder I can see to change. Was hard to see, but I caught a subtle change in appearance on one side, so decided to let it cool back down and check. And... IT WORKED! All 3 pins separated out, toned out every pin on the MCU just to be sure and everybody was in their happy place. Top of the board is a bit sticky, but who cares, this things' gonna work!!Back in the house, almost 9pm now, and yeeeeeehah it flashes! I restore some of my SPI code bits (had unwound a bunch trying to get the "wrong" chip to work) and - literally right back to where I was with the wrong chip. Logic analyzer shows MISO pin go low exactly one time for a couple clock cycles, but after that it stays high no matter what. Back to comparing old (working) code to new code, back through datasheets for the MCU and the DRV chip, but nothing I try budges it. Finally a bit after 11 I am out of gas and go to bed knowing a sleepless night lays ahead. I will say - not to brag - that I had great success with that sleepless night!Up at quarter to 6 this morning to try to get some brain time before day job starts. But really nothing. No clues, nothing obvious. If it was somehow mysteriously connected high, SPI wouldn't work to even flash the chip, nor would I see it go low the one time. I decide the only smart thing to do is to document what I'm fighting as well as I can and post it to AVRfreaks so that actual smart people might see it during the day and by the time now gets here, I've got some ideas.I post schematics for the MCU and the DRV chip, and I notice the DRV in my schematic is still listing theDRV8145(a 46-amp rated version of the 30-ampDRV8144I'm using, and the chip I started with when the 8144s were out of stock). So, as I'm typing that up, I add a note that says "The schematic shows DRV8145, but it's just a higher-current version of the chip I'm using. Same footprint and pinout." And as I wrote that, I thought "hmmmm - I think that's true, but I should triple-check to make sure." So, I pull up the two data sheets side-by-side. Sure enough, pinout is identical. But, with both of them up next to each other, I see that they look visually just a bit... Different.And, sure enough, the two chips are different sizes - one's a half mm wider and shorter than the other. So, I have the footprint for the larger DRV8145S, but I've soldered on the DRV8144S.It's enough that it looks like when the pins on the long side line up, the pins on the short side will have barely any overlap with their pads. Any one of those 4 pins being disconnected would explain why I cannot "wake it up" and get it to do anything useful.I have a few 8145s already soldered to my very first round of boards that was assembled by PCBWAY (which had many other issues making them nice paperweights). So, I'm going to attempt to snag a couple of those, get them cleaned up, and likely assemble and build a couple more boards with them this weekend to see if finally I can get at least a board or two fully functioning.I'm 6 self-assembled boards in, and I feel like the first functional one is semi-imminent. Then again, I have felt that way at least 3 times in the last few weeks, so who knows!