3. Create a component
This embedded tool helps template ato
code based on a component. Today, it supports JLCPCB components.
This embedded tool helps template ato
code based on a component. Today, it supports JLCPCB components.
It can run as both an interactive tool, or with command line arguments. Go ahead and run it interactively.
You’ll be prompted for a search term of a component. This may be:
- A JLCPCB part number (for example
C7426
) - An exact manufacturer part number (for example
NE5532DR
)
Enter C7426
and press enter.
ato create component search
Go ahead and tap Enter
through the default options.
The new component
Let’s break it down.
The component
keyword tells the compiler that a new component class is being specified, which is a subclass of module
.
The lcsc_id
attribute tells the compiler it can pick that JLCPCB part to fill this spot.
The manufacturer
and mpn
attributes together tell fully specify which component this is as well.
If you’re making a component class of a specific component, it’s typically a good idea to include at least either the lcsc_id
or the mpn
+ manufacturer
.
The datasheet_url
and designator_prefix
attributes are optional, but it’s a good idea to include them. They’re self-explanatory.
pin
Use the pin
keyword to define electrical interfaces, which the compiler maps to pads on the footprint.
That is, pin 2
says:
- Create a signal named
2
(the compiler treats pins as a special-case where they may have an integer name) - Connect the signal to pad “2” on the footprint
Good practice
Here are a few recommended tweaks to your component class:
Abstract classes
When you’re creating a class representing a specific component, for which there’s a generic abstract class (for example, an LDO
), import and subclass that abstract class to get its generic methods and attributes.
For example, you should update the component class like this:
Then, connect its pins to the LDO’s signals, set known attributes etc…
Take the mpn
and manufacturer
from ato create component
mpn
and manufacturer
are only interpreted properly if they exactly match a component in the database.