Skip to main content
Built-in Elements

<assembly.cablewire />

assembly.cablewire is one insulated conductor of its parent assembly.cable. It says which contact the wire leaves at the cable's from end and which contact it lands on at the to end. Wires feed harness drawings and the cable's parts list; they do not create electrical traces.

import { assembly } from "tscircuit"

export default () => (
<assembly.device>
<board width={40} height={20} routingDisabled>
<connector name="J1" standard="jst_sh" pinCount={4}
footprint="jst4_sh" pcbX={-12} />
<connector name="J2" standard="jst_ph" pinCount={4}
footprint="jst4_ph" pcbX={12} />
</board>
<assembly.cable name="SENSOR" from=".J1" to=".J2"
model="adaptercable_a(jst_sh_pins4)_b(jst_ph_pins4)"
length="100mm" lengthTolerance="5mm" wireAwg={28}
fromConnectorName="SH" toConnectorName="PH">
<assembly.cablewire name="GND" fromPin={1} toPin={2} color="black" />
<assembly.cablewire name="3V3" fromPin={2} toPin={1} color="red" />
<assembly.cablewire name="SDA" fromPin={3} toPin={3} color="blue" />
<assembly.cablewire name="SCL" fromPin={4} toPin={4} color="yellow" />
</assembly.cable>
<assembly.drawing.page name="sensor-adapter" width={200} height={125}>
<assembly.drawing.harnessview cableRef="SENSOR"
width={180} height={60} centerY={28} />
<assembly.drawing.wiringtable cableRef="SENSOR" title="WIRING"
paperX={0} paperY={-12} anchorAlignment="top_center" />
</assembly.drawing.page>
</assembly.device>
)
Drawing 1 of 1: sensor-adapter

Properties​

PropertyTypeDescription
fromPinnumber | stringRequired contact position on the connector at the cable's from end: 1 or "pin1".
toPinnumber | stringRequired contact position on the connector at the cable's to end.
namestringSignal or conductor name, such as "SDA". Shown in the wiring list's SIGNAL column.
colorstringInsulation color as it should read on the drawing, such as "black" or "red/white".
awgnumber | stringConductor gauge: 22 or "22awg". Omit to inherit the cable's wireAwg.

Pins are positions on the cable's plugs, counted from 1. They are not the pin labels of the board connectors the cable mates with.

Rules​

  • Each contact takes at most one wire at each end.
  • A pin number cannot exceed the connector's contact count.
  • A cavity with no wire is left empty.
  • A cable with numbered contacts needs at least one wire before it can appear in a harness view or a wiring list.

Generate wires from data​

Wires are ordinary JSX children, so a pinout array can produce them:

import { assembly } from "tscircuit"

const pinout = [3, 1, 5, 2, 8, 4, 6, 7]

export default () => (
<assembly.device>
<board width={40} height={20} routingDisabled>
<connector name="J1" standard="jst_ph" pinCount={8}
footprint="jst8_ph" pcbX={-12} />
<connector name="J2" standard="jst_ph" pinCount={8}
footprint="jst8_ph" pcbX={12} />
</board>
<assembly.cable name="SHUFFLE" from=".J1" to=".J2"
length="120mm" wireAwg={26}>
{pinout.map((toPin, index) => (
<assembly.cablewire key={toPin} fromPin={index + 1} toPin={toPin} />
))}
</assembly.cable>
<assembly.drawing.page name="shuffled-pinout" width={200} height={135}>
<assembly.drawing.harnessview cableRef="SHUFFLE"
width={180} height={62} centerY={32} />
<assembly.drawing.wiringtable cableRef="SHUFFLE"
paperX={0} paperY={-5} anchorAlignment="top_center" />
</assembly.drawing.page>
</assembly.device>
)
Drawing 1 of 1: shuffled-pinout