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.

ato create component

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

component Texas_Instruments_NE5532DR:
    """Texas_Instruments_NE5532DR component"""
    lcsc_id = "C7426"
    manufacturer = "Texas Instruments"
    mpn = "NE5532DR"
    datasheet_url = "https://www.lcsc.com/datasheet/lcsc_datasheet_1809301912_Texas-Instruments-NE5532DR_C7426.pdf"
    designator_prefix = "U"

    # pins
    signal IN1_ ~ pin 2
    signal IN1plus ~ pin 3
    signal IN2_ ~ pin 6
    signal IN2plus ~ pin 5
    signal OUT1 ~ pin 1
    signal OUT2 ~ pin 7
    signal VCC__GND ~ pin 4
    signal VCCplus ~ pin 8

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:

component Texas_Instruments_NE5532DR from LDO:

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.