Settings

Theme

Automating everything in a USB cable tester PCB design

jitx.com

77 points by caydenpiercehax 3 years ago · 42 comments

Reader

caydenpiercehaxOP 3 years ago

When I started designing PCBs a few years ago (after some years of electronics prototyping and software engineering) I was somewhat shocked by the manual, repetitive tasks I kept doing.

So, I tried to automate as many of these small tasks as possible in the simplest design I could think of - a USB cable tester PCB.

Please share your thoughts, ideas, criticism - I'm looking forward to hearing any feedback from the HN community!

  • contingencies 3 years ago

    A very simple thus unconvincing demonstration.

    Real world board designs usually have critical placement, mechanical, EMI, test, assembly, anti-RE, supply-chain or other business-level constraints.

    Without evolving the fundamental requirements definition to a language that holistically allows the parametric expression of these factors, generated designs are unlikely to meet real world needs in most real world (non-trivial) use cases.

    • caydenpiercehaxOP 3 years ago

      Thanks for the feedback. There's definitely a lot more that goes into a serious design. I purposefully chose a simpler design to experiment with automating the easy but repetitive stuff.

      To address a few points and how software-defined electronics actually does make sense for it:

      > critical placement You can use a `place` command to exactly place things wherever you want.

      > mechanical Use board outline functions, `place` commands, arbitrary shapes, 3D component shapes, etc. to meet these needs. You can export a STP and send to your mech team for validation.

      > supply-chain Parametric search query function allow designers to specify only as much information as they need about a component (e.g. 0402 10k, but not MPN) and the system can pick the best component at compile time that is in stock with necessary quantity available.

    • mschuster91 3 years ago

      Yeah, but it's a good starting point for an MVP that reduces a lot of the tedious bullshit (like calculating LED resistor values). You can always re-route paths and replace components when you're going from MVP to product based on your constraints.

      • crote 3 years ago

        I am not convinced that it is actually faster, though.

        The tricky part of PCB design is getting the right data: pre-made footprints are wrong more often than not, and automatically retrieving things like a LED's forward voltage or current are just a pipe dream.

        Doing the actual calculation takes you all of 10 seconds, and you only have to do it a few times for basically any board. Writing the shown code would probably take me longer.

      • ilyt 3 years ago

        Right, if it was a part of an existing design tools, but this appears to be entirely separate thing ?

        In most cases the "fiddly things humans" do appear more in more complex design. Keyboards and LEDs matricses like this are kinda edge case, in most if you have that many parts you have to be careful, especially if it is mixed analog/digital design.

  • spuz 3 years ago

    Nice project. I'm interested in the cable tester itself. Why does each line require a different resistor? Also, in the gif at the top of the page, it looks like some of your cables only light up 5 LEDs. Are some cables out there really that bad?

    • junon 3 years ago

      If an LED fries out, then the current will change across the other ones. If they're all going through a single current limiting resistor, then the current across the other LEDs will change, potentially frying them all out due to overcurrent scenarios. This is the case for many different areas of PCB design.

      Further, all LEDs have different responses to current (as LEDs are non-linear components and thus ohm's law doesn't apply) and thus usually require different current limiting resistors to achieve similar brightness or in some cases color.

      Also, switching LEDs on an off will affect the cathode net and anything connected to it, so it'd also affect the other LEDs in parallel depending on which are on and off at any given point.

    • DHaldane 3 years ago

      Each LED has a different response for how much light you get out based on how much current goes in. To get the same brightness you have to compensate for that. (Default behavior is one super dim LED, and one that is like staring at the sun.)

      Code for the LEDs is here: https://github.com/JITx-Inc/jitx-cookbook/blob/main/usb_c_ca...

      And yeah, cables are that bad. Can't tell you how much time is lost to figuring out why your device won't enumerate on USB and then finding the cable was the culprit.

    • mschuster91 3 years ago

      > Are some cables out there really that bad?

      Some cables just connect the bare minimum for USB connectivity - +5V/GND. I've seen that one on vape charger cables. Others go a bit further and add the USB 2.0 D+/D-.

    • Evidlo 3 years ago

      If LEDs share a resistor then they dim as more LEDs are turned on.

      • spuz 3 years ago

        I meant to say why does each LED require a different resistor value?

        • dfox 3 years ago

          Because different colors usually mean different semiconductor material and thus different forward voltage of the junction which in practical terms leads to different brightness if the same resistor value is used.

        • ilyt 3 years ago

          Different color have different forward voltage and luminosity per mA.

          Or if it is connected to some live signal the signal itself might be with different voltage range

  • hakfoo 3 years ago

    I wanted to do a custom keyboard, at one point I tried to write some PHP code to parse a JSON definition of the layout, and generate a disposable Python script to feed into the KiCAD console to position the switches and diodes to order. (Mostly because I far comfier with PHP tooling) It sort of fell apart because I couldn't quite get the diodes to lay out where I wanted them.

    • ilyt 3 years ago

      There is extremely lazy way to do it.

      Pick a switch footprint and add diode footprint to it, save as new footprint.

      • crote 3 years ago

        The problem is that this often isn't physically possible.

        Keyboards are rarely fully grid-like, so you have to take into account that there is a row/column shift. Modern keyboards have features like per-key RGB and hotswap sockets, which eat up a lot of valuable space. And then you also have to fit half a dozen traces in between two switches for the key matrix connectivity.

        An approach like that might work for a trivial macropad, but it quickly falls apart on a full-size keyboard.

        • ilyt 3 years ago

          Right. We're talking about someone making a one off that's simple enough to mostly auto place with a script.

          > And then you also have to fit half a dozen traces in between two switches for the key matrix connectivity.

          ...I guess you never designed a PCB? there is loads of space on keyboard sized design.

          • DHaldane 3 years ago

            The interesting thing about scripting layout is how quickly you need an autorouter. There's usually plenty of room, but if things aren't laid out extremely regularly with no variation, it rare to be able to just write out the correct component positions and copper shapes.

        • LeifCarrotson 3 years ago

          Keyswitches are like 20x20mm...there's an abundance of room for a little ~2x1mm diode within the footprint.

          • hakfoo 3 years ago

            It's a bit harder if you go through-hole. When you can't fit it "under" the switch footprint, it becomes harder to auto-route it-- there might not be a space specifically where you want-- maybe you want to move some diodes around to shave a couple millimetres off the PCB footprint to save a nickel, or maybe you need to rotate a switch (for example, the + and enter on the numeric pad) and end up with the 'standard' position fouling some other part of the layout.

            It takes an evening or two to manually route a big battleship board, when you're not worried about RGB or having to do clever stuff with USB.

  • jareklupinski 3 years ago

    this is something I could use with my box of cables, I like the idea of the battery onboard and just leakage current when off

    can the script bundle the LEDs together to make it easier to visually grok the results? e.g. this bundle of LEDs lit up means it's a usb3 compliant cable, this bundle lit up means the cc resistors are proper, etc

    the brightness may be a good thing, if you add a faceplate to diffuse the LEDs (and add proper labels/branding). I've been meaning to find a good application for a PCB faceplate... https://hackaday.com/2022/08/17/circuit-less-pcb-featured-as...

    • caydenpiercehaxOP 3 years ago

      Great idea. Yeah, that could be done.

      First pass would be to bundle the LEDs based on their type - just change the ordering from an ordering based on physical position to an ordering based on the logical meaning of each connection.

      In the second pass, you could have a separate LED bank with LEDs marked USB3, USB2, etc. Hook those up to a couple of logic gates so that the LED turns on when it detects the USB3, USB2, etc. configuration.

    • DHaldane 3 years ago

      That's a cool idea. Can confirm that this brightness is good if you need to check cable quality in full outdoor sun.

  • RobotToaster 3 years ago

    Shame it's using a proprietary SaaS. An electronics version of openSCAD sounded interesting.

  • ta988 3 years ago

    Your website on my phone cuts the text on the left with Firefox. Even zooming in/out doesn't allow me to see it, only desktop mode.

magtux 3 years ago

PCB design is a complex process with many factors to consider, such as routing and placement for mechanical, EMI, and thermal performance. As a hobbyist, I was initially drawn to the library and auto router features of PCB design software. However, as I gained experience, I came to realize that it is often better to do things manually. This allows for more control and ensures that there are no unwanted changes due to automation. Additionally, manual design is often more efficient in the long run, as it can prevent the need for recomputation.

In my experience, the paradigm of programmatically generating PCBs is not always practical. Even as a hobbyist, I eventually switched to manual design after experiencing issues with automated tooling. If you are serious about PCB design, you need to do things manually. There are other teams depending on the information and it needs to be guaranteed to be correct.

  • naikrovek 3 years ago

    > If you are serious about PCB design, you need to do things manually.

    this will not always be the case, you know.

    I hate that this blog post is effectively an HTML commercial for the product they are selling, but I have to admit that they are headed in the right direction.

    Prior to tools like KiCad, "serious" users did tapeout by hand. Prior to the transistor, "serious" electronic engineers used vacuum tubes.

    • DHaldane 3 years ago

      Hey, founder here - we really value feedback from HN and I try to cut out all of the commercial aspects and just write something interesting.

      Do you have some feedback about what we could change about this article to make it less like a commercial?

      • naikrovek 3 years ago

        nothing specific; all "here's how I used this tool my company makes to do a thing" blog posts on the company site itself are just inherently ads.

        I find it disingenuous every time I see it, because (while nothing is done to imply this) it reads, at first, like a genuine blog post someone wrote on a personal site.

        we all read enough blog posts every day that the site hosting the blog can easily go unnoticed, and I feel like companies hope that "blog fatigue" will make the post look more spontaneous and genuine than it is.

        I often forget that YCombinator is a greenhouse for companies to be fed and watered and pruned so they can become standalone entities out in the wild, and that this means that I'll be presented with blog posts about products from the product-makers themselves.

ilyt 3 years ago

I always wanted parts of PCB/schematic designs to be automated, like ability to say "here is LC filter, pick LC values to match 5kHz with this accuracy using E24 parts, with L being below X uH in value value", or plain "autoroute those less important paths after I did the important one" but I'm not sure how I feel about making it entirely in code.

  • caydenpiercehaxOP 3 years ago

    Yeah totally agree, circuit generators are powerful. There's a lot of cases where you decide your higher level constraints (e.g. I want a filter of this architecture) and the rest is plug and play with equations, which can (SHOULD) be automated.

    I've enjoyed the jump to "code-first" PCB design but can understand your point - any thoughts on a UI that would allow these programmatic constructs interleaved with more classical EDA workflow?

  • Ccecil 3 years ago

    Kicad's RF attenuator tool looks like it is close to that use case.

    https://docs.kicad.org/7.0/en/pcb_calculator/pcb_calculator....

eimrine 3 years ago

Why the board is photographed only from one side?

  • _Microft 3 years ago

    I think it is either a single layer board or the back side is empty anyways.

    The complexity certainly does not require a board with two or more layers. Here is how it is made up:

    Positive pole goes to the pins of the connector on the left-hand side, negative pole to the ground fill (look closely to the right connection at the battery and you will see how it connects to the area with the lighter shade of green on the board - this is a copper area shining through the green solder mask).

    On the right hand side, the different pins of the connector are wired to the test points, resistors and diodes which at the other end connect to the ground fill. Now if a cable is plugged in both sockets and if there is a connection on a particular pin of that cable, the circuit for the respective LED is closed and it lights up.

  • caydenpiercehaxOP 3 years ago

    It's a 2 layer PCB. I put all the components on one side for simpler PCBA.

    The other side of the board is pretty boring - just a ground plane and a couple traces. Like others said, this whole thing could be done on a single layer if you wanted.

  • ilyt 3 years ago

    I assume because routing on the other looks ugly xD

    • Karliss 3 years ago

      If the PCB was connecting two connectors together with testpoints in the middle that might have been the case.

      But it is much simpler than that. Right above photo there is a gif showing that all the pins for one connector are connected to battery, while other connector connects to LEDS and afterwards ground.

  • ThatPlayer 3 years ago

    Looks like a single layer PCB

    • ilyt 3 years ago

      It does not look like single layer PCB in the slightest and it is probably and at least 2 side

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection