aj0070/rs485-io

A 100×70 mm industrial I/O PCB with protected 24 V power conversion, RP2040 control, isolated RS-485, eight opto-isolated digital inputs, and four transistor-driven relay outputs.

Version
1.0.0
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone aj0070/rs485-io  # download the package files into ./rs485-io
tsci add aj0070/rs485-io    # add it to your project as @tsci/aj0070.rs485-io

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

dist/index.js

import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
import React from 'react';

// 24 V field input -> fuse, TVS, reverse-polarity Schottky, 5 V buck, 3.3 V LDO.
// Schematic sheet: Power (sheet 0).
const PowerBlock = () => (jsxs(Fragment, { children: [jsx("connector", { name: "J1", footprint: "pinrow2_p5.08mm", pinLabels: { pin1: "V24", pin2: "GND" }, schPinArrangement: { topSide: ["V24"], bottomSide: ["GND"] }, connections: { pin1: "net.V24", pin2: "net.GND" }, allowOffBoard: true, pcbX: -46, pcbY: 24, pcbRotation: 90, schSheetName: "Power", schX: -12, schY: 9, children: jsx("footprint", { insertionDirection: "from_above" }) }), jsx("fuse", { name: "F1", footprint: "1206", currentRating: "1.5A", voltageRating: "32V", connections: { pin1: "net.V24", pin2: "net.V24_F" }, pcbX: -45, pcbY: 15.5, schSheetName: "Power", schX: -9, schY: 9, schRotation: 0 }), jsx("diode", { name: "D1", footprint: "smb", variant: "tvs", connections: { pin1: "net.GND", pin2: "net.V24_P" }, pcbX: -45.5, pcbY: 11.5, schSheetName: "Power", schX: -3, schY: 9, schRotation: 90 }), jsx("diode", { name: "D2", footprint: "smb", connections: { pin1: "net.V24_F", pin2: "net.V24_P" }, pcbX: -45.5, pcbY: 6.5, schSheetName: "Power", schX: -6, schY: 9, schRotation: 0 }), jsx("capacitor", { name: "C1", footprint: "electrolytic_d8mm_p3.5mm", capacitance: "100uF", maxVoltageRating: "50V", polarized: true, connections: { pin1: "net.V24_P", pin2: "net.GND" }, pcbX: -44, pcbY: -0.5, schSheetName: "Power", schX: -1, schY: 6, schRotation: 270 }), jsx("chip", { name: "U3", footprint: "soic8", manufacturerPartNumber: "TPS5430DDA", pinLabels: {
                pin1: "BOOT",
                pin2: "NC1",
                pin3: "NC2",
                pin4: "VSENSE",
                pin5: "ENA",
                pin6: "GND",
                pin7: "VIN",
                pin8: "PH",
            }, noConnect: ["NC1", "NC2"], connections: {
                BOOT: "net.BOOT",
                VSENSE: "net.FB",
                ENA: "net.EN",
                GND: "net.GND",
                VIN: "net.V24_P",
                PH: "net.PH",
            }, pcbX: -38, pcbY: 12, schSheetName: "Power", schX: -6, schY: 0, schWidth: 2.055, schHeight: 1 }), jsx("capacitor", { name: "C3", footprint: "0603", capacitance: "10nF", connections: { pin1: "net.BOOT", pin2: "net.PH" }, pcbX: -38, pcbY: 16.5, schSheetName: "Power", schX: 4, schY: -2, schRotation: 270 }), jsx("diode", { name: "D3", footprint: "smb", connections: { pin1: "net.GND", pin2: "net.PH" }, pcbX: -33, pcbY: 5.5, schSheetName: "Power", schX: -1.5, schY: 0, schRotation: 270 }), jsx("inductor", { name: "L1", footprint: "1210", inductance: "15uH", maxCurrentRating: "2A", connections: { pin1: "net.PH", pin2: "net.V5" }, pcbX: -32, pcbY: 12, schSheetName: "Power", schX: 1.5, schY: 0, schRotation: 0 }), jsx("capacitor", { name: "C4", footprint: "1206", capacitance: "22uF", maxVoltageRating: "16V", connections: { pin1: "net.V5", pin2: "net.GND" }, pcbX: -40, pcbY: 25.5, schSheetName: "Power", schX: 3, schY: 6, schRotation: 270 }), jsx("capacitor", { name: "C5", footprint: "1206", capacitance: "22uF", maxVoltageRating: "16V", connections: { pin1: "net.V5", pin2: "net.GND" }, pcbX: -35, pcbY: 25.5, schSheetName: "Power", schX: 4.1, schY: 6, schRotation: 270 }), jsx("resistor", { name: "R1", footprint: "0603", resistance: "10k", connections: { pin1: "net.V5", pin2: "net.FB" }, pcbX: -33, pcbY: 16.5, schSheetName: "Power", schX: -9.5, schY: 1.5, schRotation: 270 }), jsx("resistor", { name: "R2", footprint: "0603", resistance: "3.24k", connections: { pin1: "net.FB", pin2: "net.GND" }, pcbX: -30, pcbY: 16.5, schSheetName: "Power", schX: -9.5, schY: -0.5, schRotation: 270 }), jsx("resistor", { name: "R3", footprint: "0603", resistance: "100k", connections: { pin1: "net.V24_P", pin2: "net.EN" }, pcbX: -38, pcbY: 21, schSheetName: "Power", schX: -3, schY: 1.5, schRotation: 270 }), jsx("resistor", { name: "R4", footprint: "0603", resistance: "20k", connections: { pin1: "net.EN", pin2: "net.GND" }, pcbX: -34.5, pcbY: 21, schSheetName: "Power", schX: -3, schY: -0.5, schRotation: 270 }), jsx("chip", { name: "U4", footprint: "sot223", manufacturerPartNumber: "AMS1117-3.3", pinLabels: { pin1: "GND", pin2: "VOUT", pin3: "VIN", pin4: "VOUT_TAB" }, connections: {
                GND: "net.GND",
                VOUT: "net.V3_3",
                VIN: "net.V5",
                VOUT_TAB: "net.V3_3",
            }, pcbX: -35, pcbY: -1, schSheetName: "Power", schX: 6, schY: -4, schWidth: 2.2, schHeight: 0.6 }), jsx("capacitor", { name: "C6", footprint: "0805", capacitance: "10uF", connections: { pin1: "net.V5", pin2: "net.GND" }, pcbX: -27.5, pcbY: -2.5, schSheetName: "Power", schX: 5.2, schY: 6, schRotation: 270 }), jsx("capacitor", { name: "C7", footprint: "0805", capacitance: "10uF", connections: { pin1: "net.V3_3", pin2: "net.GND" }, pcbX: -14, pcbY: -6.5, schSheetName: "Power", schX: 9, schY: 6, schRotation: 270 }), jsx("resistor", { name: "R5", footprint: "0603", resistance: "1k", connections: { pin1: "net.V3_3", pin2: "net.LED_PWR_A" }, pcbX: -48.5, pcbY: -5.8, pcbRotation: 180, schSheetName: "Power", schX: -2, schY: -6, schRotation: 270 }), jsx("led", { name: "LED1", footprint: "0603", color: "green", pinLabels: { pin1: "cathode", pin2: "anode" }, supplierPartNumbers: { jlcpcb: ["C2904374"] }, connections: { pin1: "net.GND", pin2: "net.LED_PWR_A" }, pcbX: -48.5, pcbY: -8.6, schSheetName: "Power", schX: -2, schY: -8.5, schRotation: 270 }), jsx("testpoint", { name: "TP1", footprintVariant: "pad", padShape: "circle", padDiameter: "1.2mm", connections: { pin1: "net.V5" }, pcbX: -3, pcbY: 1.5, schSheetName: "Power", schX: 13, schY: 0 }), jsx("testpoint", { name: "TP2", footprintVariant: "pad", padShape: "circle", padDiameter: "1.2mm", connections: { pin1: "net.V3_3" }, pcbX: -1, pcbY: -1, schSheetName: "Power", schX: 13, schY: -6 })] }));

const rp2040Pins = {
    pin1: "IOVDD6",
    pin2: "GPIO0",
    pin3: "GPIO1",
    pin4: "GPIO2",
    pin5: "GPIO3",
    pin6: "GPIO4",
    pin7: "GPIO5",
    pin8: "GPIO6",
    pin9: "GPIO7",
    pin10: "IOVDD5",
    pin11: "GPIO8",
    pin12: "GPIO9",
    pin13: "GPIO10",
    pin14: "GPIO11",
    pin15: "GPIO12",
    pin16: "GPIO13",
    pin17: "GPIO14",
    pin18: "GPIO15",
    pin19: "TESTEN",
    pin20: "XIN",
    pin21: "XOUT",
    pin22: "IOVDD4",
    pin23: "DVDD2",
    pin24: "SWCLK",
    pin25: "SWD",
    pin26: "RUN",
    pin27: "GPIO16",
    pin28: "GPIO17",
    pin29: "GPIO18",
    pin30: "GPIO19",
    pin31: "GPIO20",
    pin32: "GPIO21",
    pin33: "IOVDD3",
    pin34: "GPIO22",
    pin35: "GPIO23",
    pin36: "GPIO24",
    pin37: "GPIO25",
    pin38: "GPIO26_ADC0",
    pin39: "GPIO27_ADC1",
    pin40: "GPIO28_ADC2",
    pin41: "GPIO29_ADC3",
    pin42: "IOVDD2",
    pin43: "ADC_AVDD",
    pin44: "VREG_IN",
    pin45: "VREG_VOUT",
    pin46: "USB_DM",
    pin47: "USB_DP",
    pin48: "USB_VDD",
    pin49: "IOVDD1",
    pin50: "DVDD1",
    pin51: "QSPI_SD3",
    pin52: "QSPI_SCLK",
    pin53: "QSPI_SD0",
    pin54: "QSPI_SD2",
    pin55: "QSPI_SD1",
    pin56: "QSPI_SS",
    pin57: "GND",
};
// RP2040, QSPI flash, 12 MHz crystal, SWD header and decoupling.
// Schematic sheet: MCU (sheet 1).
const McuBlock = () => (jsxs(Fragment, { children: [jsx("chip", { name: "U1", footprint: "qfn56_thermalpad3.1mmx3.1mm_p0.4001mm_w7.8999mm_h7.9001mm_pw0.2mm_pl0.85mm", manufacturerPartNumber: "RP2040", pinLabels: rp2040Pins, noConnect: [
                "GPIO15",
                "GPIO16",
                "GPIO17",
                "GPIO18",
                "GPIO19",
                "GPIO20",
                "GPIO21",
                "GPIO22",
                "GPIO23",
                "GPIO24",
                "GPIO26_ADC0",
                "GPIO27_ADC1",
                "GPIO28_ADC2",
                "GPIO29_ADC3",
                "USB_DM",
                "USB_DP",
            ], connections: {
                IOVDD1: "net.V3_3",
                IOVDD2: "net.V3_3",
                IOVDD3: "net.V3_3",
                IOVDD4: "net.V3_3",
                IOVDD5: "net.V3_3",
                IOVDD6: "net.V3_3",
                USB_VDD: "net.V3_3",
                VREG_IN: "net.V3_3",
                ADC_AVDD: "net.V3_3",
                VREG_VOUT: "net.V1_1",
                DVDD1: "net.V1_1",
                DVDD2: "net.V1_1",
                GND: "net.GND",
                TESTEN: "net.GND",
                RUN: "net.RUN",
                XIN: "net.XIN",
                XOUT: "net.XOUT",
                SWCLK: "net.SWCLK",
                SWD: "net.SWDIO",
                GPIO0: "net.IN_1",
                GPIO1: "net.IN_2",
                GPIO2: "net.IN_3",
                GPIO3: "net.IN_4",
                GPIO4: "net.IN_5",
                GPIO5: "net.IN_6",
                GPIO6: "net.IN_7",
                GPIO7: "net.IN_8",
                GPIO8: "net.RELAY_1",
                GPIO9: "net.RELAY_2",
                GPIO10: "net.RELAY_3",
                GPIO11: "net.RELAY_4",
                GPIO12: "net.RS485_TX",
                GPIO13: "net.RS485_RX",
                GPIO14: "net.RS485_DE",
                GPIO25: "net.LED_ST_A",
                QSPI_SS: "net.QSPI_SS",
                QSPI_SCLK: "net.QSPI_SCLK",
                QSPI_SD0: "net.QSPI_SD0",
                QSPI_SD1: "net.QSPI_SD1",
                QSPI_SD2: "net.QSPI_SD2",
                QSPI_SD3: "net.QSPI_SD3",
            }, pcbX: -15, pcbY: 5, schSheetName: "MCU", schX: 0, schY: 0, schWidth: 2.815, schHeight: 6 }), jsx("chip", { name: "U10", footprint: "wson", manufacturerPartNumber: "W25Q16JVUXIQ", pinLabels: {
                pin1: "CS",
                pin2: "IO1",
                pin3: "IO2",
                pin4: "GND",
                pin5: "IO0",
                pin6: "CLK",
                pin7: "IO3",
                pin8: "VCC",
                pin9: "EP",
            }, noConnect: ["EP"], connections: {
                CS: "net.QSPI_SS",
                IO1: "net.QSPI_SD1",
                IO2: "net.QSPI_SD2",
                IO0: "net.QSPI_SD0",
                CLK: "net.QSPI_SCLK",
                IO3: "net.QSPI_SD3",
                VCC: "net.V3_3",
                GND: "net.GND",
            }, pcbX: -25, pcbY: 2, schSheetName: "MCU", schX: -7, schY: 3, schWidth: 1.77, schHeight: 1.2 }), jsx("crystal", { name: "Y1", frequency: "12MHz", loadCapacitance: "12pF", pinVariant: "four_pin", footprint: "crystal4_px2.5mm_py2mm", maxTraceLength: "25mm", connections: {
                pin1: "net.XIN",
                pin2: "net.GND",
                pin3: "net.XOUT",
                pin4: "net.GND",
            }, pcbX: -15.8, pcbY: -1.5, schSheetName: "MCU", schX: -4.75, schY: -1, schWidth: 2.2, schHeight: 1.8 }), jsx("pinheader", { name: "J2", pinCount: 4, pitch: "2.54mm", footprint: "pinrow4_p2.54mm", pinLabels: ["V3_3", "SWDIO", "SWCLK", "GND"], connections: {
                pin1: "net.V3_3",
                pin2: "net.SWDIO",
                pin3: "net.SWCLK",
                pin4: "net.GND",
            }, pcbX: 4, pcbY: 17, pcbRotation: 90, schSheetName: "MCU", schX: -11, schY: 0, schWidth: 0.675 }), jsx("capacitor", { name: "C10", footprint: "0603", capacitance: "1uF", connections: { pin1: "net.V1_1", pin2: "net.GND" }, pcbX: -8, pcbY: 9.5, schSheetName: "MCU", schX: 4, schY: -6, schRotation: 270 }), jsx("capacitor", { name: "C11", footprint: "0603", capacitance: "100nF", connections: { pin1: "net.V1_1", pin2: "net.GND" }, pcbX: -8, pcbY: 7, schSheetName: "MCU", schX: 5.1, schY: -6, schRotation: 270 }), jsx("capacitor", { name: "C12", footprint: "0603", capacitance: "100nF", connections: { pin1: "net.V3_3", pin2: "net.GND" }, pcbX: -8, pcbY: 4.5, schSheetName: "MCU", schX: 4, schY: -8.5, schRotation: 270 }), jsx("capacitor", { name: "C13", footprint: "0603", capacitance: "100nF", connections: { pin1: "net.V3_3", pin2: "net.GND" }, pcbX: -16, pcbY: 10.5, pcbRotation: 180, schSheetName: "MCU", schX: 5.1, schY: -8.5, schRotation: 270 }), jsx("capacitor", { name: "C14", footprint: "0603", capacitance: "100nF", connections: { pin1: "net.V3_3", pin2: "net.GND" }, pcbX: -12.5, pcbY: 10.5, schSheetName: "MCU", schX: 6.2, schY: -8.5, schRotation: 270 }), jsx("capacitor", { name: "C15", footprint: "0603", capacitance: "100nF", connections: { pin1: "net.V3_3", pin2: "net.GND" }, pcbX: -19.2, pcbY: 10.5, schSheetName: "MCU", schX: 7.3, schY: -8.5, schRotation: 270 }), jsx("capacitor", { name: "C16", footprint: "1206", capacitance: "1uF", connections: { pin1: "net.V3_3", pin2: "net.GND" }, pcbX: -7.5, pcbY: 1.5, schSheetName: "MCU", schX: 8.4, schY: -8.5, schRotation: 270 }), jsx("resistor", { name: "R10", footprint: "0603", resistance: "10k", connections: { pin1: "net.V3_3", pin2: "net.RUN" }, pcbX: 0, pcbY: 4, schSheetName: "MCU", schX: -5, schY: 2, schRotation: 270 }), jsx("resistor", { name: "R11", footprint: "0603", resistance: "10k", connections: { pin1: "net.V3_3", pin2: "net.QSPI_SD2" }, pcbX: -26.5, pcbY: -7.5, schSheetName: "MCU", schX: -9.5, schY: 1, schRotation: 270 }), jsx("resistor", { name: "R12", footprint: "0603", resistance: "10k", connections: { pin1: "net.V3_3", pin2: "net.QSPI_SD3" }, pcbX: -23.5, pcbY: -7.5, schSheetName: "MCU", schX: -9.5, schY: -1, schRotation: 270 }), jsx("resistor", { name: "R13", footprint: "0603", resistance: "1k", connections: { pin1: "net.LED_ST_A", pin2: "net.LED_ST_K" }, pcbX: 1.5, pcbY: -2, schSheetName: "MCU", schX: 4, schY: -2, schRotation: 270 }), jsx("led", { name: "LED2", footprint: "0603", color: "red", pinLabels: { pin1: "cathode", pin2: "anode" }, supplierPartNumbers: { jlcpcb: ["C2904374"] }, connections: { pin1: "net.GND", pin2: "net.LED_ST_K" }, pcbX: 1.5, pcbY: -5, schSheetName: "MCU", schX: 4, schY: -4.5, schRotation: 270 }), jsx("capacitor", { name: "C17", footprint: "0603", capacitance: "12pF", connections: { pin1: "net.XIN", pin2: "net.GND" }, pcbX: -19.6, pcbY: -2, schSheetName: "MCU", schX: -5.5, schY: -4, schRotation: 270 }), jsx("capacitor", { name: "C18", footprint: "0603", capacitance: "12pF", connections: { pin1: "net.XOUT", pin2: "net.GND" }, pcbX: -11.4, pcbY: -1.5, schSheetName: "MCU", schX: -4, schY: -4, schRotation: 270 })] }));

// ISO3082 isolated RS-485 with B0505S isolated supply, 120 ohm termination
// jumper, fail-safe bias and SM712 TVS. Schematic sheet: RS485 (sheet 2).
const Rs485Block = () => (jsxs(Fragment, { children: [jsx("chip", { name: "U5", footprint: "soic16", manufacturerPartNumber: "ISO3082", pinLabels: {
                pin1: "VCC1",
                pin2: "GND1",
                pin3: "R",
                pin4: "RE_N",
                pin5: "DE",
                pin6: "D",
                pin7: "NC1",
                pin8: "GND1B",
                pin9: "GND2",
                pin10: "NC2",
                pin11: "NC3",
                pin12: "B",
                pin13: "A",
                pin14: "NC4",
                pin15: "GND2B",
                pin16: "VCC2",
            }, noConnect: ["NC1", "NC2", "NC3", "NC4"], connections: {
                VCC1: "net.V3_3",
                GND1: "net.GND",
                GND1B: "net.GND",
                R: "net.RS485_RX",
                RE_N: "net.RS485_DE",
                DE: "net.RS485_DE",
                D: "net.RS485_TX",
                GND2: "net.ISO_GND",
                GND2B: "net.ISO_GND",
                A: "net.RS485_A",
                B: "net.RS485_B",
                VCC2: "net.ISO_5V",
            }, pcbX: 41, pcbY: 8, pcbRotation: 0, schSheetName: "RS485", schX: 0, schY: 2, schWidth: 2.15, schHeight: 1.8 }), jsx("chip", { name: "U6", footprint: "pinrow4_p2.54mm", manufacturerPartNumber: "B0505S-1W", pinLabels: { pin1: "VIN_N", pin2: "VIN_P", pin3: "VOUT_N", pin4: "VOUT_P" }, connections: {
                VIN_N: "net.GND",
                VIN_P: "net.V5",
                VOUT_N: "net.ISO_GND",
                VOUT_P: "net.ISO_5V",
            }, pcbX: 29, pcbY: 1, schSheetName: "RS485", schX: -5.5, schY: 2, schWidth: 2.245, schHeight: 0.6 }), jsx("capacitor", { name: "C20", footprint: "0603", capacitance: "100nF", connections: { pin1: "net.V3_3", pin2: "net.GND" }, pcbX: 35.5, pcbY: 4, pcbRotation: 180, schSheetName: "RS485", schX: -2.5, schY: 5, schRotation: 270 }), jsx("capacitor", { name: "C21", footprint: "0805", capacitance: "10uF", connections: { pin1: "net.V3_3", pin2: "net.GND" }, pcbX: 35.5, pcbY: 7, pcbRotation: 180, schSheetName: "RS485", schX: -1.4, schY: 5, schRotation: 270 }), jsx("capacitor", { name: "C22", footprint: "0603", capacitance: "100nF", connections: { pin1: "net.ISO_5V", pin2: "net.ISO_GND" }, pcbX: 46, pcbY: 6, schSheetName: "RS485", schX: 2.5, schY: 5, schRotation: 270 }), jsx("capacitor", { name: "C23", footprint: "0805", capacitance: "10uF", connections: { pin1: "net.ISO_5V", pin2: "net.ISO_GND" }, pcbX: 46, pcbY: 9, schSheetName: "RS485", schX: 3.6, schY: 5, schRotation: 270 }), jsx("resistor", { name: "R20", footprint: "0805", resistance: "120", connections: { pin1: "net.RS485_TERM", pin2: "net.RS485_B" }, pcbX: 38, pcbY: 20.5, pcbRotation: 0, schSheetName: "RS485", schX: 8.5, schY: 4, schRotation: 270 }), jsx("solderjumper", { name: "JP1", footprint: "solderjumper2", pinLabels: { pin1: "A", pin2: "TERM" }, connections: { pin1: "net.RS485_A", pin2: "net.RS485_TERM" }, pcbX: 39.7, pcbY: 16.5, pcbRotation: 180, schSheetName: "RS485", schX: 10, schY: 4, schRotation: 270 }), jsx("chip", { name: "D20", footprint: "sot23", manufacturerPartNumber: "SM712", pinLabels: { pin1: "A", pin2: "B", pin3: "GND" }, connections: { A: "net.RS485_A", B: "net.RS485_B", GND: "net.ISO_GND" }, pcbX: 47, pcbY: 13, schSheetName: "RS485", schX: 6.5, schY: 1.5, schWidth: 1.58, schHeight: 0.6 }), jsx("resistor", { name: "R21", footprint: "0603", resistance: "680", connections: { pin1: "net.ISO_5V", pin2: "net.RS485_A" }, pcbX: 45.5, pcbY: 0, schSheetName: "RS485", schX: 5.5, schY: 3.5, schRotation: 270 }), jsx("resistor", { name: "R22", footprint: "0603", resistance: "680", connections: { pin1: "net.RS485_B", pin2: "net.ISO_GND" }, pcbX: 48.5, pcbY: 0, schSheetName: "RS485", schX: 5.5, schY: 0, schRotation: 270 }), jsx("connector", { name: "J3", footprint: "pinrow3_p5.08mm", pinLabels: { pin1: "A", pin2: "B", pin3: "COM" }, connections: { pin1: "net.RS485_A", pin2: "net.RS485_B", pin3: "net.ISO_GND" }, pcbX: 46, pcbY: 26, pcbRotation: 90, allowOffBoard: true, schSheetName: "RS485", schX: 10, schY: -2, children: jsx("footprint", { insertionDirection: "from_above" }) })] }));

const INPUT_CHANNELS = [1, 2, 3, 4, 5, 6, 7, 8];
// Eight opto-isolated 24 V digital inputs (PC817 class), each with a series
// resistor, indicator LED, reverse diode and a 10k pull-up on the logic side.
// Schematic sheets: Inputs A (3) and Inputs B (4).
const InputsBlock = () => (jsx(Fragment, { children: INPUT_CHANNELS.map((ch, i) => {
        const x = -42 + i * 12;
        const schX = -12 + (i % 4) * 7;
        const sheet = ch <= 4 ? "Inputs A" : "Inputs B";
        return (jsxs(React.Fragment, { children: [jsx("connector", { name: `J${10 + ch}`, footprint: "pinrow2_p5.08mm", pinLabels: { pin1: "IN", pin2: "COM" }, schPinArrangement: { topSide: ["COM"], bottomSide: ["IN"] }, connections: { pin1: `net.FIELD_IN_${ch}`, pin2: "net.FIELD_COM" }, allowOffBoard: true, pcbX: x, pcbY: -29, pcbRotation: 270, schSheetName: sheet, schX: schX, schY: 8, children: jsx("footprint", { insertionDirection: "from_above" }) }), jsx("resistor", { name: `R${30 + ch}`, footprint: "1206", resistance: "2.2k", connections: { pin1: `net.FIELD_IN_${ch}`, pin2: `net.IN_LED_${ch}` }, pcbX: x - 3.5, pcbY: -15.5, schSheetName: sheet, schX: schX, schY: 5, schRotation: 270 }), jsx("led", { name: `LED${10 + ch}`, footprint: "0603", color: "red", pinLabels: { pin1: "cathode", pin2: "anode" }, supplierPartNumbers: { jlcpcb: ["C2904374"] }, connections: { pin1: `net.IN_OPTO_${ch}`, pin2: `net.IN_LED_${ch}` }, pcbX: x + 3.5, pcbY: -15.5, schSheetName: sheet, schX: schX, schY: 2.5, schRotation: 270 }), jsx("chip", { name: `U${20 + ch}`, footprint: "dip4", manufacturerPartNumber: "PC817", pinLabels: { pin1: "A", pin2: "K", pin3: "E", pin4: "C" }, connections: {
                        A: `net.IN_OPTO_${ch}`,
                        K: "net.FIELD_COM",
                        C: `net.IN_${ch}`,
                        E: "net.GND",
                    }, pcbX: x, pcbY: -20, schSheetName: sheet, schX: schX, schY: -1.5, schWidth: 1.39, schHeight: 0.6 }), jsx("resistor", { name: `R${40 + ch}`, footprint: "0603", resistance: "10k", connections: { pin1: "net.V3_3", pin2: `net.IN_${ch}` }, pcbX: x, pcbY: -6.3, pcbRotation: 270, schSheetName: sheet, schX: schX + 4, schY: -1.5, schRotation: 270 })] }, ch));
    }) }));

const OUTPUT_CHANNELS = [1, 2, 3, 4];
// Four relay outputs: G6K-2P DIP8 signal relay, NPN driver, base pull-down,
// flyback diode and a 3-pin COM / NO / NC terminal. Schematic sheet: Outputs (5).
const OutputsBlock = () => (jsx(Fragment, { children: OUTPUT_CHANNELS.map((ch, i) => {
        const x = [-23, -5, 13, 31][i];
        const schX = -12 + (i % 4) * 7;
        return (jsxs(React.Fragment, { children: [jsx("chip", { name: `K${ch}`, footprint: "dip8", manufacturerPartNumber: "G6K-2P-DC5", pinLabels: {
                        pin1: "COIL_P",
                        pin2: "NC1",
                        pin3: "COM1",
                        pin4: "NO1",
                        pin5: "NO2",
                        pin6: "COM2",
                        pin7: "NC2",
                        pin8: "COIL_N",
                    }, noConnect: ["NO2", "COM2", "NC2"], connections: {
                        COIL_P: "net.V5",
                        COIL_N: `net.RELAY_K_${ch}`,
                        NC1: `net.RELAY_NC_${ch}`,
                        COM1: `net.RELAY_COM_${ch}`,
                        NO1: `net.RELAY_NO_${ch}`,
                    }, pcbX: x, pcbY: 22, schSheetName: "Outputs", schX: schX, schY: 4, schWidth: 2.34, schHeight: 1 }), jsx("transistor", { name: `Q${ch}`, type: "npn", footprint: "sot23", connections: {
                        base: `net.RELAY_B_${ch}`,
                        collector: `net.RELAY_K_${ch}`,
                        emitter: "net.GND",
                    }, pcbX: x, pcbY: 12.5, schSheetName: "Outputs", schX: schX + 3, schY: 1 }), jsx("resistor", { name: `R${50 + ch}`, footprint: "0603", resistance: "1k", connections: { pin1: `net.RELAY_${ch}`, pin2: `net.RELAY_B_${ch}` }, pcbX: x - 4.5, pcbY: 12.5, schSheetName: "Outputs", schX: schX, schY: -2, schRotation: 270 }), jsx("resistor", { name: `R${54 + ch}`, footprint: "0603", resistance: "10k", connections: { pin1: `net.RELAY_B_${ch}`, pin2: "net.GND" }, pcbX: x, pcbY: 9, schSheetName: "Outputs", schX: schX + 2, schY: -2, schRotation: 270 }), jsx("diode", { name: `D${50 + ch}`, footprint: "sod123", connections: { pin1: `net.RELAY_K_${ch}`, pin2: "net.V5" }, pcbX: x + 4.6, pcbY: 12.5, schSheetName: "Outputs", schX: schX + 4.5, schY: 1, schRotation: 270 }), jsx("connector", { name: `J${20 + ch}`, footprint: "pinrow3_p5.08mm", pinLabels: { pin1: "COM", pin2: "NO", pin3: "NC" }, connections: {
                        pin1: `net.RELAY_COM_${ch}`,
                        pin2: `net.RELAY_NO_${ch}`,
                        pin3: `net.RELAY_NC_${ch}`,
                    }, allowOffBoard: true, pcbX: x, pcbY: 31, schSheetName: "Outputs", schX: schX + 2, schY: 7, children: jsx("footprint", { insertionDirection: "from_above" }) })] }, ch));
    }) }));

var index_circuit = () => (jsxs("board", { width: "100mm", height: "70mm", layers: 2, title: "Isolated RS-485 industrial I/O module", partsEngineDisabled: true, routeRemaining: true, children: [jsx("net", { name: "GND", isGroundNet: true }), jsx("net", { name: "V3_3", isPowerNet: true }), jsx("net", { name: "V5", isPowerNet: true }), jsx("net", { name: "V24", isPowerNet: true }), jsx("net", { name: "V24_F" }), jsx("net", { name: "V24_P" }), jsx("net", { name: "V1_1" }), jsx("net", { name: "ISO_5V" }), jsx("net", { name: "ISO_GND" }), jsx("net", { name: "FIELD_COM" }), jsx("schematicsheet", { name: "Power", displayName: "24 V input, 5 V buck, 3.3 V LDO", sheetIndex: 0 }), jsx("schematicsheet", { name: "MCU", displayName: "RP2040, QSPI flash, clock, SWD", sheetIndex: 1 }), jsx("schematicsheet", { name: "RS485", displayName: "Isolated RS-485", sheetIndex: 2 }), jsx("schematicsheet", { name: "Inputs A", displayName: "Opto inputs 1-4", sheetIndex: 3 }), jsx("schematicsheet", { name: "Inputs B", displayName: "Opto inputs 5-8", sheetIndex: 4 }), jsx("schematicsheet", { name: "Outputs", displayName: "Relay outputs 1-4", sheetIndex: 5 }), jsx("hole", { name: "H1", diameter: "3.2mm", pcbX: -40, pcbY: 32.5 }), jsx("hole", { name: "H2", diameter: "3.2mm", pcbX: 41, pcbY: 32.5 }), jsx(PowerBlock, {}), jsx(McuBlock, {}), jsx(Rs485Block, {}), jsx(InputsBlock, {}), jsx(OutputsBlock, {})] }));

export { index_circuit as default };