banner
News center
We implement a flawless quality system to ensure excellent product output.

Exploring Code

Jun 06, 2023

Unlike programming, where a developer can write a function to use many times elsewhere in the program, circuit board design is still very lacking in this feature set. For example, creating an arranging a grid of LEDs with connections to certain pins or adding a test pad for each of a connector's inputs can take a long time to accomplish. But as Cayden Pierce shows in his latest PCB project, modern tools such as JITX enable engineers to create boards by writing code rather than selecting footprints, thus allowing for a wide range of possibilities in automation and extensibility.

A good example of this technique is creating a breakout/testing board for cables, as each pin needs a test pad, LED, and a label. Beyond these requirements, Pierce's USB-C cable tester would also need a different current limiting resistor value for each LED due to the differences in brightness between them. For wire within the USB cable, a voltage would be sent from the source end and received at the other end which is connected to both a test pad and a current-limited LED that lights up if the wire is conducting properly.

The first step of designing the PCB involved defining a power net for the positive voltage line and connecting all pins on the "source" USB connector to it. From here, test points were defined within a loop that assigns a label and places it near the pad, as well as connecting the pad to its associated pin on the other USB connector. The LEDs were also defined programmatically, except the creation function also takes into account the color when selecting the resistor value due to uneven brightness levels between colors.

Traditionally, moving from the schematic to the PCB phase of circuit design in a legacy EDA tool involves dragging each footprint onto the board and running traces according to the nets which takes a long time. Pierce, however, was able to programmatically set where he wanted each test pad/resistor/LED set through some simple arithmetic within the same loop as where they are defined. The last step was to use JITX's autorouter feature that automatically runs traces between components with minimal human intervention.

By opting for a code-first design, Pierce showcased how he could save hours of time when designing his USB-C cable testing PCB compared to traditional methods. In the future, he could easily add more components, additional lines, or other connectors and quickly generate routes and layouts. You can read his code and the tutorial in more detail here in his blog post.