PCB Review: STM32 Breakout Board with odd configuration - Page 1
Forum section: electronics / general

author: RarePossum
author_rank: Contributor
timestamp: August 01, 2024, 01:29:20 am
content: Hi,I'm looking for feedback on this STM32 based PCB design. I do realised the positioning of the pins is quite odd, but I'm trying to keep most of them onto two sides. Main points of feedback I'm looking for are:Its using two TRRS cables to communicate via UART to other boards of the same design. I current have R1 and R2 crossing over to account for this, not sure if its correctCrystal and USB wiring. Also the use of the ESD, never used one before so not 100% if its been wired correctlyOther general feedback would be welcome too though.Thanks for the help

author: ataradov
author_rank: Super Contributor
timestamp: August 01, 2024, 02:12:58 am
content: Your VBUS pins on the USB connector are not connected. You can see the blue ratsnest line.It is often easier to use opposite side pins on the ESD protection IC (3-4 or 6-1) and pass both traces under the IC. It does not really matter, just more aesthetically pleasing.You need to be very careful with TRRS connectors. When a jack is inserted or removed, tip and inner rings will make contact with all other pins. Even if you are not expecting connections under power, there is always a chance for accidental disconnection. And having VBUS on there does not help.

author: RarePossum
author_rank: Contributor
timestamp: August 01, 2024, 03:28:23 am
content: Thanks for your tips, I've fixed the VBUS but left the ESD as is just because the traces are a bit easier to wire this way while keeping them similar length. Could probably move them around a bit though.For the TRRS I hadn't considered that. What about swapping them for USB receptacles instead then? Though again I'm unsure if they need to be crossed over, like I've configured below.

author: ataradov
author_rank: Super Contributor
timestamp: August 01, 2024, 03:32:22 am
content: Quote from: RarePossum on August 01, 2024, 03:28:23 amLength matching does not matter here at all. It does not really matter, it will work either way.Quote from: RarePossum on August 01, 2024, 03:28:23 amIt would be better electrically, but it is a bad idea to use USB connectors for non-USB stuff, especially if this is not a one-off project.

author: RarePossum
author_rank: Contributor
timestamp: August 01, 2024, 03:38:59 am
content: Thanks for the super quick reply. This is a one off, but do you have any suggestion for what receptacles to use then? Most options that came up in an initial search looked a little big for me, or I couldn't find a corresponding receptacle.And I jsut found JST XH so those should work.

author: ataradov
author_rank: Super Contributor
timestamp: August 01, 2024, 04:39:44 am
content: JST connectors are a good option.Your VBUS connection for J2 is weird. There is no need for a via, since connector pin hole is a via on its own.

author: quadtech
author_rank: Regular Contributor
timestamp: August 01, 2024, 05:37:20 am
content: Consider using RJ45 for the UART connectors - you could even use ready made cableslike Cisco router console cables which are RJ45.

author: RarePossum
author_rank: Contributor
timestamp: August 01, 2024, 06:10:19 am
content: The via is fixed now, and I appreciate all the tips you've given.I'll have to remember using RJ45 in the future, it seems quite convenient, but in this case its probably cheaper for me to use JSTs.Any other feedback would be good if you can spot it, the main spot I'm not 100% on is how I've done the crystal.

author: ataradov
author_rank: Super Contributor
timestamp: August 01, 2024, 06:31:58 am
content: The crystal looks fine to me. But I personally use CMOS generators. It avoids all possible issues with the crystals, plus you don't need to stock a bunch of random low pF value capacitors. And the proce difference for low volume stuff is insignificant.

author: tooki
author_rank: Super Contributor
timestamp: August 01, 2024, 08:25:12 am
content: Quote from: RarePossum on August 01, 2024, 03:38:59 amWell the answer depends on the purpose. In the original post you say it’s to link multiple boards, but you don’t state whether that cable is external or not, i.e. are the boards connected and then left alone (as might be common if they were within an enclosure), or are they intended to be frequently connected/disconnected by the user?JST XH is great for internal wiring, but IMHO very unsuited for external connections, because they a) require a lot of force to unmate, and b) have very minimal strain relief (and even that only when crimped with original JST crimp tools; third-party crimpers tend to screw up the insulation crimp,* actuallycreatinga weak spot right where strain relief is needed!).A connector that is not bad as an occasional-disconnect external cable is Molex Micro-Fit 3.0. Molex even sells overmolded cables for certain pin counts.For “real” external cables with connectors intended for frequent use, you may struggle to find a PCB-mount option. Modular cables (like 8P8C (RJ-45) or 4P4C (handset cord)) are a good choice if the compatible cable is suitable for your application. (In your case, it’s not going to be critical at all.)Where space is not an issue, good old d-sub can be a solid choice.Binder makes some nice little circular connectors like Series 719/709.If you want fancier, things like Lemo ($$ ) or cheap Chinese clones thereof are nice.*Whereas in most open-barrel crimp contacts the insulation crimp is intended to be folded into the center and gently penetrate into (but not through!) the insulation, JST XH has extra-long insulation crimp wings which the crimp tool rolls into full cylinders that do not penetrate the insulation at all, but rather just apply pressure to the insulation. This is a much “taller” profile overall, so typical non-JST crimpers drive those extra-long insulation wings into the insulation, but since they’re so long, they pierce right through the insulation and compress it significantly, weakening it. XH has the insulation crimp flush with the housing, so this weak spot is precisely at the place where flexing occurs.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 01, 2024, 08:30:24 am
content: Layout of a board like this on 4 layers is easy. It looks doable on 2 with a decent GND plane, but it's a tradeoff between cost and layout time.I think you used a few microvia's. There is no need to do this at all on this PCB, and it does make manufacturing more complex / expensive.Don't put via's through pads. It does not matter much for hand soldering, when using a solder stencil, the amount of solder is fixed, and most of the solder will wick into the via, which then starves the connection of solder.Don't make long rows of via's that interrupt the GND plane. Pull those via's apart so the GND plane can connect in between, or make small groups of via's.With KiCad's default settings pads of THT connectors are so big that combined with their clearance the prevent the GND plane from fitting in between pads. This is a bit unfortunate. But because you have a 4 layer PCB, you can:PCB Editor / Tools / Remove Unused Pads. KiCad does not have a full padstack yet, but withRemove Unused Padsyou can remove the pads from the copper layers that have no connection, and this leaves more room for the GND plane (and for routing tracks on internal layers).Also, what did you do with the 4th copper layer? With the most common PCB production process, layers always come in sets or 2, regardless of whether you use them or not. Even having both internal layers as a big GND zone is better. It improves EMI performance, because the core of the PCB is much thicker then a prepreg layer. It reduces the gap between a signal track from around 1.4mm, to 0.2mm.I have not had many PCB's produced, but uneven copper can apparently be a reason for warped PCB's, and for that reason it is recommended to approximately balance the amount of copper on "symmetrical" layers.Outline of the PCB has some slanted lines. Is this intentional? It's quite easy to make lines horizontal / vertical if you work on a coarse grid. I also like round numbers for mechanical things, so I usually use a grid of 1mm or 5mm for the PCB outline and mounting holes.

author: thm_w
author_rank: Super Contributor
timestamp: August 01, 2024, 09:08:59 pm
content: USBC, TRRS, or RJ45 are all fine for this if you properly protect the inputs and outputs. TRRS I guess is more work since it has to take a short circuit for sure. USBC you have to have some awareness of what c-c cables connect internally, though in this case its just a few pins.https://www.pshinecable.com/article/usb-c-cable-wiring-diagram.htmlYou can always use the JST and then wire that to a chassis mount connector I guess.Some commercial products:https://www.amazon.com/KINESIS-Advantage360-Split-Ergonomic-Keyboard/dp/B0BCHFHX6V?th=1https://www.amazon.com/Mistel-MD600RGB-Mechanical-Keyboard-Programmable/dp/B09KNFS7MJ

author: RarePossum
author_rank: Contributor
timestamp: August 02, 2024, 12:39:20 am
content: Quote from: tooki on August 01, 2024, 08:25:12 amIts intended to be left alone for the most part, but I removing it occasionally wouldn't be unexpected, I like the look of the Molex Micro fits, but I'm once again not 100% on whether I should be crossing them over. Though I guess if I add the wires myself it doesn't really matter.Quote from: Doctorandus_P on August 01, 2024, 08:30:24 amI've moved the vias to address those points now. The microvias, I checked a quote and shouldn't have a cost difference but I'll check again. I've also checked the THT and the power planes do go in between the THT so that should be fine too. The 4th plane just has a few routing signals on it and nothing else. So its Signals + Components, GND, 3v3, then minor routing.I was thinking of adding a GND or VBUS plane to it, leaning towards GND.

author: tooki
author_rank: Super Contributor
timestamp: August 02, 2024, 11:02:12 am
content: Quote from: RarePossum on August 02, 2024, 12:39:20 amAnd inside or outside of an enclosure? If the cabling is outside, how much will it get flexed? This will determine the amount of strain relief needed.About crossing over the UART TX/RX lines:In the schematic you swapped the GND and VBUS. Surely that isn’t your intent?!?As for whether or not to cross them over in hardware, I’m not really sure what the confusion is: TX of the sending device needs to go to RX of the receiving device.If you’re getting your head in knots because of the question of “TX vs RX from whose point of view?”, just come up with better terminology yourself. (For example, in one project where I had an MCU and a fairly powerful Bluetooth module, I just named the UART lines something like “UART_MCUtoBT” and “UART_BTtoMCU” to make it unambiguous which way the data flows.)Whether you need to swap them kinda depends on the situation: if boards are always connected from a right-side UART to a left-side UART, then you can cross over the lines on one of the two jacks. But if there’s the possibility of a right-side jack connecting to another right-side jack (or left to left), then you really need to do the crossover in the cable.You could just use GPIOs that the TX and RX lines can be assigned to freely. Then you can just swap them in software if needed. For example, you could even use code that dynamically swaps them if it doesn’t receive anything within a certain amount of time. (Make this timeout a somewhat randomized time so you don’t have two boards swapping simultaneously!) Of course this also means your code needs to make sure to try and send something for the other board to receive, again with randomized delay to avoid collisions.Or don’t use UART at all, and instead use a bidirectional electrical bus, like I2C, 2-wire, or CAN for short distances, or RS-485 or Ethernet for longer ones. (RS-485 would need transceiver ICs of course, and Ethernet a PHY and magnetics, unless that MCU has a built in PHY.) In theory you could also make your own open-collector/open-drain bus, too. With a true bus, you also have the option of having only one tap per MCU and instead using addressing to marshal data to the correct node. Or use more hardware and have independent buses to daisy-chain, eliminating addressing (but requiring the MCU to pass messages along).It might be prudent for you to share more about the overall project, as that makes it much easier to make concrete recommendations.

author: free_electron
author_rank: Super Contributor
timestamp: August 02, 2024, 03:49:44 pm
content: J2 and J3 have power and ground reverse. better not mix the cables !.inject two 0805 10 ohm resistors in tx and rx pairs and place them crossed. that way you can swap tx and rx if needed by installing resistors horizontal or vertical. you can also do this with a 2x2 header. use diametrically opposite corners for the cpu pins and the other corners for the outgoing signal. depending how you plug the jumpers you can cross the signals.On to USB. First, your tvs diode breaks the differential pair. Use a different one where you can route-through. d3v3f4ulp for example or pesd4usb3. If you don't want SON packages you can use one of the sot23 flavored ones like UDT23a03 or DESD3v3 or DESD5v0Route the the d+/d- zig-zag through so you don't break coupling. yeah yeah, there's going to be people that claim it's not all that important, but do it right. The internet is already full of crap designs that become gospel.on the USB connector : do NOT tie the shield to ground directly. it defeats the purpose of shield. The ground pin of the USB connector is the reference for the VBUS and the data lines. The shield is a braided sleev that goes over all wires. In a properly constructed cable there should not be no electrical connection between ground and the shield.USB connectors are constructed so that shield will always contact BEFORE any other wires. So any potential difference between two devices ( leakage, static charge, whatnot ) get shunted there. You do not hit the data lines with the equalisation. it is a chassis tie strap. Next the power and ground pins will connect ( they are longer than the data lines) . This equalizes the power domain ( system ground) , lastly the data lines. At this point there is no energy remaining to cause harm to the transceivers. So why do you need TVS diodes ? the cable can be capacitively charged ( shield to internal wires) and that charge displacement during equalisation can inject into the drivers. That is what the TVS diodes are for.The shield is a chassis ground. You tie that using an R//C to the system ground ON THE SLAVE device.The USB host will have the shield tied to its chassis ground that will be hard shunted to system ground.So there is a difference between a host and a slave !Any fast pulse will be shunted through the capacitor. The parallel resistor is there to bleed off the capacitor so that it does not accumulate a static DC voltage and blows through its dielectric. 4n7 // 1 meg or 10nf // 100k will do the trick. you can lower the resistor if needed. Use an automotive grade cap rated for high voltage ( 200v+) they can survive ESD pulses.further reading:https://passive-components.eu/mlccs-for-electrostatic-discharge-esd-protection-in-automotive-applications-vishay-white-paper/https://article.murata.com/en-us/article/esd-resistance-of-capacitorshttp://ww1.microchip.com/downloads/en/AppNotes/doc8388.pdf

author: thm_w
author_rank: Super Contributor
timestamp: August 02, 2024, 08:39:48 pm
content: Quote from: free_electron on August 02, 2024, 03:49:44 pmYeah no. We had this discussion many times.https://www.eevblog.com/forum/projects/why-usb-c-gnd-is-being-connected-to-the-shield-of-the-cable-after-connecting/https://www.eevblog.com/forum/beginners/on-devices-side-should-i-connect-usb-cable-shielding-to-the-black-wire/?topicseenQuote

author: RarePossum
author_rank: Contributor
timestamp: August 03, 2024, 01:57:25 am
content: It should be outside of an enclosure but not move too much, might be bumped every so often but otherwise untouched.My intent is to daisy chain several of these boards together via the UART, with the right UART going to the left UART, and be powered from a single board. I have VBUS and GND crossing over because if the cables are straight through, they'd shoort without. I drew my thinking below.Its not supposed to be used by anyone other than me, so left should always go to right, but I'm also aware that I have a chance of fucking it up if I get distracted so now I'm leaning to cross-over in the cables.I guess could also just use 6 pins and not worry about it.

author: tooki
author_rank: Super Contributor
timestamp: August 03, 2024, 01:31:55 pm
content: Quote from: RarePossum on August 03, 2024, 01:57:25 amOk, we’ve got a terminology issue here, then. A “straight through” cable means one where every pin connects to the same-numbered pin on both ends, i.e. pin 1 to pin 1, 2 to 2, 3 to 3, etc., regardless of how the wires in the cable lay.“Straight through” does NOT mean a cable where the wires gophysicallystraight across, connecting two plugs back to back, connecting each pin to whatever pin it happens to be facing from the rear, which I think is what you assumed it to mean.“Crossover” is actually a term fairly specific to Ethernet cables, as far as I know. In RS-232, a functionally equivalent cable (which swaps TX and RX, but not the other lines!) is called a “null modem” cable.FYI, some general advice:In ribbon cables (the kind terminated to IDC connectors), always keep the stripe (on non-rainbow cable) or brown (=1 in resistor color code) on the end with the pin 1 marker arrow.In RJ45 cables, follow TIA-568 color code. For a straight through cable use 568B on both ends, for crossover use 568B on one end and 568A on the other.4P4C (phone handset) cables are a bit of a “gotcha”, in that both straight-through cables (order of colors the same on both ends, as viewed from the mating side, meaning that one plug is facing up and the other is facing down), and reversed cables (both plugs facing up, meaning the order of the colors is reversed on one end) exist. When replacing a handset cord, one should look at the old one and see which was used.Whatever connector you use for a given application, always look at the datasheets to determine how the pins are numbered, ensuring you triple-check whether the numbering is shown from the back (wire side) or front (mating surface), and which direction is “up”, and then triple-check that your PCB footprint matches this; these can be wrong, even “official” ones. Learn how a given connector marks one, if at all. And with connectors that are available from multiple vendors (like basic 0.1” headers, KK-style connectors, JST, and many others), triple-check whether the version you’re using numbers pins the same way as the other vendors, because they sometimes switch it around!!! (For example, I had an issue with cheap Molex KK clones that had the pin 1 marker on the opposite side as original Molex.) FWIW, I’ve almost entirely abandoned using cheap clone connectors and opt for original name-brand now.

author: tooki
author_rank: Super Contributor
timestamp: August 03, 2024, 01:40:21 pm
content: Quote from: RarePossum on August 03, 2024, 01:57:25 amAnd let me reiterate my request that you share more about the project.I don’t understand why some people here are often so reluctant to share what their project is, what it does, etc. Some mistakenly believe that by withholding that information, they will keep people focused on their specific issue, but mostly that just leads to less-focused discussion because without context, unsuited suggestions get discussed. And you miss out on potentially superior overall solutions.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 03, 2024, 02:58:45 pm
content: I did not look closely at the schematic, because I have a strong dislike for putting everything in rectangular boxes with same size / boldness titles.The boxes do not add anything that whitespace does not do better, and the boxes often get redrawn / resized muliple times during schematic design and refactoring. I really liked the schematic as drawn in the project below:https://www.eevblog.com/forum/eda/pcb-review-thermostat-pcb/Just whitespace and bigger titles for the blocks makes it easier and quicker to get an overview.Direct serial connections over pluggable (power + data) cables definitely needs more attention then this. First, the 3.5mm audio plugs create all kind of (temporary) shorts during (un-)plugging. Exposed uC pins on external connectors need some extra protection such as TVS diodes.For the Rx / Tx thing. It's a nuisance to deal with. I2C may work, as long as the cables are relatively short (2m or so) but my own preference is to use RS485 drivers. This simply puts the two signal wires parallel to each other. Cables can be long (1km on lower baudrates) and their inherent common mode range insures communication still works properly if you loose a few volts from the power supply over long cables (Upto around 7V in shift in GND level!) For the protocol, I wrote my own (with 16-bit address space and also 16 bit CRC), but if you want to keep it simple, then there are already plenty of libraries available, You can for example use MODBUS.

author: RarePossum
author_rank: Contributor
timestamp: August 04, 2024, 03:38:29 am
content: Its going to be used to connect bunch of switches on a second PCB to act as a USB input device. For now this is just going to be some small ~40% keyboards, but I also plan on trying it with a gamepad. It's only going to be used by me and maybe some friends, and mostly be left on my dekstop.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 04, 2024, 07:33:05 am
content: Quote from: RarePossum on August 01, 2024, 01:29:20 amFor the connectors, I very much prefer to use a single dual pin header for all the pins.1. It's more sturdy then single row connectors.2. It allows for either a single board to board connector or a flatcable.3. With a flatcable, you can separate individual wires to connect to external things such as switches or leds in for example a front panel.4. It still allows for mating with single row headers or "dupont" wires.5. It's more compact.Routing power to the pins connectors is also common. If you have any secondary IC's they will also need to be powered.There is no mounting hole on this PCB. Mounting holes are nice to have.I also solder big GND loops to all of my (experimental) projects. A bent piece of copper wire (2.5 square mm), bent with a radius of approximately 10mm. It's an instantly recognizable and solid connection for the GND clip of your scope or crocodile clamps of other measuring equipment.

author: tooki
author_rank: Super Contributor
timestamp: August 04, 2024, 12:29:50 pm
content: Quote from: RarePossum on August 04, 2024, 03:38:29 amFor me this falls squarely in the realm of something that requires a cable intended for external use, with real strain relief. So unless you use an overmolded cable from Molex, I probably wouldn’t use Micro-Fit. The overmolded cables come no shorter than 500mm, which may be too long for you.If it isn’t too long, also look at the single-row variant, which is flatter than the dual-row one you put on the PCB. Might be useful, depending on your mechanical design. Look at the drawing:https://www.molex.com/content/dam/molex/molex-dot-com/products/automated/en-us/salesdrawingpdf/214/214770/2147700405_sd.pdfYou would need a single-row header like 43650-0403 or 43650-0411.And of course the overmolded cable uses straight-through (by number) wiring, so you would have to cross the RX/TX lines on the PCB. (Or, as I said but you didn’t react to, by reassigning them in software, provided you assign them a pair of pins that have that flexibility.)Another connector type you could consider, even though it’s not intended for data, is the mini-XLR connector. But I don’t think anyone makes the jacks in PCB mount, so you’d have to mount those in a case.Or mini-DIN.Or you could even use USB connectorswith actual USB signalsby integrating a USB hub controller chip, with one downstream port connecting the MCU, and one or two downstream ports allowing you to plug in further devices. Each one would simply be its own keyboard/gamepad, which Windows/Mac/Linux are perfectly happy with. (The only limitation would be that you couldn’t implement functions that rely on detecting key combinations from separate keyboards, since each one wouldn’t know the state of the others.)

author: tooki
author_rank: Super Contributor
timestamp: August 04, 2024, 12:45:42 pm
content: Quote from: Doctorandus_P on August 04, 2024, 07:33:05 amAll true, but it’s important to mention the big downside to this approach: the ease of accidentally connecting something incorrectly, with the corresponding risk of damage. So often, dedicated headers (ideally using polarized connectors) are a better choice.It certainly does not make any sense to integrate the programming header into a big unified connector.Quote from: Doctorandus_P on August 04, 2024, 07:33:05 amIn this case, I assume that everything other than the UART ports for daisy-chaining are primarily the key scan lines, maybe with a few LEDs. There won’t be any other ICs, other than complete modules via the UART ports, which have power on them.Quote from: Doctorandus_P on August 04, 2024, 07:33:05 amOr buy nice prebent things like these:https://www.digikey.com/en/products/detail/keystone-electronics/1430-3/2746419With clever use of round jumpers of different sizes, you can make nice “jacks” for oscilloscope probes that contact both the ground and signal.Or if there’s room on the PCB, just make a large plated through-hole or slot right at the edge of the board. You can similarly make PTHs of specific diameters to accept a multimeter probe (2mm) or oscilloscope probe (usually 0.5mm).

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 04, 2024, 04:33:16 pm
content: Quote from: tooki on August 04, 2024, 12:45:42 pmMeh, a single big keyed dual row box header and you're golden.Putting nicely readable Silkscreen on the PCB helps with individual wires.Quote from: tooki on August 04, 2024, 12:45:42 pmHmm, yes, I wast just thinking about I/O, power and GND.Quote from: tooki on August 04, 2024, 12:45:42 pmI thought the goal was to have a semi-universal board, put a bunch of them together to talk over the same cable in a network, and then have each (mostly) do it's own thing.Quote from: tooki on August 04, 2024, 12:45:42 pmWHAT??? Are you mad?Paying 56ct for a piece of bent wire, and then waiting for it to arrive for who knows how long? It can take months to save up a shopping list to get into the "free postage" price range. But I admit, it is an option. Low value shunt resistors can also be abused for this.

author: tooki
author_rank: Super Contributor
timestamp: August 04, 2024, 04:47:26 pm
content: Quote from: Doctorandus_P on August 04, 2024, 04:33:16 pmWe now know what the real intended use is:Quote from: RarePossum on August 04, 2024, 03:38:29 amQuote from: Doctorandus_P on August 04, 2024, 04:33:16 pmCalm your tits, friend! No need for that kind of response.Quote from: Doctorandus_P on August 04, 2024, 04:33:16 pmNobody is suggesting placing an order just to buy a single one of these. But I think they’re a nice thing to have around. They’re gold plated and made of much harder wire, making them more durable than a loop of ordinary wire. Make a lot of sense for boards one anticipates doing a lot of experimentation with. And it’s just one example of deliberate test points; cheaper ones exist.And surely you are aware that DigiKey (and Mouser, Farnell, and the other big distributors) have very predicable shipping times? It’s not “who knows how long”, because you know exactly how long it will take. (Before you jump down my throat again: yes, I know that occasionally orders get held up. But it’s a tiny minority. In the last year, during which I’ve placed dozens of orders from the big distributors, I’ve had exactly one get held up. Smaller distributors like Distrelec and Conrad are a bit more unpredictable.)

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 04, 2024, 08:03:10 pm
content: Guess I made a misjudgement again.Thought the satire was obvious enough to not mention it explicitly.