<subcircuit />
Overview
A <subcircuit />
is a powerful organizational element in tscircuit that
represents a collection of elements that are tightly coupled. Subcircuits are
often used for a small functional block, such as a voltage regulator.
Within a subcircuit, you can have a custom autorouter or isolated nets from the larger circuits. You can also re-use reference designators. Your subcircuit is essentially isolated from other subcircuits.
export default () => (
<board width="10mm" height="10mm">
<subcircuit name="subcircuit1" schX={-2}>
<resistor name="R1" resistance="1k" />
</subcircuit>
<subcircuit name="subcircuit2" schX={2}>
<resistor name="R2" resistance="1k" />
</subcircuit>
<trace from=".subcircuit1 .R1 .pin1" to=".subcircuit2 .R2 .pin1" />
</board>
)
Re-using Reference Designators
Re-using reference designators is typically considered a bad practice, but in tscircuit reference designators are intelligently prefixed prior to being written on the silkscreen. This means that you can design your subcircuits without worrying about whether or not a reference designator has been previously used.
export default () => (
<board width="10mm" height="10mm">
<subcircuit name="subcircuit1" schX={-2}>
<resistor name="R1" resistance="1k" />
</subcircuit>
<subcircuit name="subcircuit2" schX={2}>
<resistor name="R1" resistance="1k" />
</subcircuit>
<trace from=".subcircuit1 .R1 .pin1" to=".subcircuit2 .R1 .pin1" />
</board>
)
Configuring the Autorouter
Subcircuits can have a custom autorouter configuration. This will be inherited by any children subcircuits.
To specify a custom autorouter configuration, just set the autorouter
property
on a <subcircuit />
element.
<subcircuit autorouter="auto-cloud">
<resistor name="R1" resistance="1k" footprint="0402" />
<resistor name="R2" resistance="1k" footprint="0402" />
{/* ... */}
</subcircuit>
Specifying custom autorouter settings for subcircuits can be extremely useful when you have a tricky section of components that have special requirements.
Read more about the autorouter prop here.