racklet / kicad-rs

Rust automation to make your PCB schematics declarative with YAML
Apache License 2.0
5 stars 1 forks source link

Create a tool for checking for component availability #11

Open chiplet opened 2 years ago

chiplet commented 2 years ago

Problem

The silicon shortage has created a problem where most components are, more often than not, out of stock. Once a popular component goes out of stock it will be out of stock virtually everywhere. In order to assemble the design one then has to look for an alternative component, revise the circuit schematic for the new component, and update the physical layout of the circuit board to match the new schematic. This is particularly difficult for hobby projects that are developed over a longer period of time. More often than not, when the design is ready for ordering the parts are no longer available. This issue is made even worse by the fact that one usually notices that an component is out of stock at the very end of the design process while ordering components for the completed design.

Goal

It would be nice to have CI tooling that could automatically check the availability of components used in circuit designs. It's possible to use KiCad key-value parameters to annotate schematics with information for identifying components and determining their values, tolerances, and so on. Based on these annotations, the step of searching for components and determining if they are available could be automated and integrated with CI tooling in a way that's already often adopted in software development.

The ultimate goal would be to have a tool that could automatically construct a BOM with links to components that are in stock based on the schematic metadata. In the case that some basic passive component is out of stock the tool should be able to automatically find a replacement. If some specific IC is out of stock, which cannot be replaced automatically the tool should give an explicit error to automate the process of discovering that your favorite component is out of stock again.

chiplet commented 2 years ago

The tool should be able to locate a suitable passive component based on schematic metadata. It would also be useful to have a way of defining global constraints e.g. for resistor tolerances or capacitor temperature ratings. I'm pretty sure the classifier tool already supports a way of annotating the components with default values based on their type.

Metadata sources:

For example let's say that the schematic contains the symbol with the following properties:

In this case the tool should be able to construct an appropriate component search, locate the cheapest/highest-in-stock component from the results and return a status that indicates if a part could be found with an associated link if the component was found. If there's a global configuration stating that all resistors should have a tolerance of at most 10% then this should be reflected in the search results as well.

chiplet commented 2 years ago

Comparing Different Distributor APIs

Digikey

The API uses OAuth 2.0 for managing end-user Digi-Key account authorization to third party "Digi-Key applications". OAuth 2.0 authentication flow relies on browser interactions for user logic, which either means that the authentication has to be done manually, or that the user credentials are given to the tool to automate the browser interactions. Neither approach is ideal for the use: manual browser login seriously hinders automation and passing the personal login information to a tool does not feel like a good idea.

It would be possible to manually request the OAuth 2.0 tokens (access token and refresh token), which could be used to authenticate. The problem with this approach is that the tokens eventually expire and would have to be periodically updated manually.

The API is rate limited to 1000 requests/day and 120 requests/minute.

Octopart

Findchips