Python Engineering Toolkit — cst
The open-source package that powers this project's templates: standards-cited calculators, a panel design pipeline, commissioning generators, PLC utilities, and diagnostics.
The toolkit lives in the same repository as this site:
github.com/kyawminthu20/Control-System-Tools
(src/cst/). Python 3.12+, standard library only at its core, with the test
suite run as a release gate on every change.
git clone https://github.com/kyawminthu20/Control-System-Tools.git
cd Control-System-Tools
uv sync # installs the cst CLI (or: pip install -e .)
uv run cst --help
Design Principles
- Every result carries its citations. Calculators return the value plus the standard clauses, formulas, and assumptions behind it — ready to paste into design notes.
- Licensed table values are never distributed. Rule logic is open; bulk table values (NEC ampacity, motor FLC, Bussmann C-values) load from files you transcribe from your own licensed copies. Clearly-marked sample data lets everything run out of the box — and warns you it’s sample data.
- One I/O list drives everything. The panel and commissioning generators all consume the same CSV, so the BOM, wire schedule, loop sheets, and FAT protocol stay consistent with each other.
What It Does
| Command | What it produces | Basis |
|---|---|---|
cst voltage-drop / wire-size |
Conductor voltage drop; minimum AWG for a drop target | NEC K-factor method; 210.19(A)/215.2(A) recommendations |
cst ampacity |
Allowable ampacity with ambient correction and bundle adjustment | NEC 310.15(B) equation, Table 310.15(C)(1) |
cst motor-branch |
Conductor, OCPD, and overload sizing for one motor | NEC Art. 430 chain (430.22, Table 430.52(C)(1), 240.6(A), 430.32) |
cst transformer |
Transformer FLA and OCPD limits | NEC Table 450.3(B) |
cst sccr |
Panel SCCR weakest-link assessment | UL 508A Supplement SB4; NEC 409.22 check |
cst fault-current |
Infinite-bus fault current + point-to-point attenuation | Bussmann method |
cst enclosure / fan |
Sealed-enclosure temperature rise; filter-fan airflow | IEC/TR 60890-style effective-surface method |
cst encoder |
Encoder scaling: counts ↔ units ↔ RPM ↔ linear speed | Kinematics |
cst io-check |
I/O list validation (duplicate tags, address conflicts) | — |
cst bom / wire-schedule / legend |
Panel design documents from the I/O list | NFPA 79 Ch. 16/19 conventions |
cst loop-sheets / fat |
Per-point loop test sheets; FAT/SAT protocol skeleton | ISA-style loop-check practice |
cst tags-from-io / modbus-map |
PLC tag database; Modbus register map | IEC 61131-3 identifier rules; Modbus data model |
cst saleae |
Pulse stats, glitch finder, quadrature decode from Logic 2 exports | — |
cst modbus-decode |
Offline Modbus TCP capture analysis: exception responses, unanswered requests, response latency, polled register spans | Modbus Application Protocol Specification V1.1b3 |
cst sbm |
Similarity-based anomaly scores for sensor data | SBM-family kernel autoassociative model |
cst twin-validate |
Digital-twin payload against the data contract: required fields, requested authority vs the register ceiling, freshness | Corpus digital_twin.md §5; NIST SP 800-82r3 |
cst twin-sync |
Synchronization health of twin telemetry: gaps, out-of-order arrivals, staleness, clock skew and drift | Corpus digital_twin.md §3 steps 2 and 4 |
cst design-package |
One markdown design document stitching the above together | — |
Example — the classic Article 430 chain for a 10 hp, 460 V motor:
$ cst motor-branch --hp 10 --volts 460 --nameplate-fla 13.2
Motor branch circuit — 10 hp, 460 V, 3-phase: 17.5 A (min conductor ampacity)
table_flc_a: 14
ocpd_max_calc_a: 35
ocpd_rating_a: 35
overload_max_a: 16.5
overload_percent: 125
Warnings:
! Loaded SAMPLE table data — demonstration values only; verify against a licensed copy and populate data/standards_tables/ before design use
Assumptions:
- Single continuous-duty motor; no other loads on the branch circuit
- Service factor 1.15, temperature rise 40 degC
- Nameplate FLA = 13.2 A
- Select actual conductor size from ampacity tables (cst.calc.ampacity) with the installation's correction/adjustment factors
References:
- NEC 2023 Table 430.250 — table FLC 14 A — NEC (NFPA 70) 2023 Table 430.250 (SAMPLE data)
- NEC 2023 430.22 — branch conductors >= 125 % of table FLC
- NEC 2023 Table 430.52(C)(1) + Exc. 1 — inverse time breaker max 250 % of FLC, next standard size permitted
- NEC 2023 240.6(A) — standard rating selected: 35 A
- NEC 2023 430.32(A)(1) — overload at 125 % of nameplate FLA
The ! Loaded SAMPLE table data line is part of the real output, not site
decoration. Until you transcribe NEC Table 430.250 from your own licensed copy
into data/standards_tables/, the 14 A table FLC above is a demonstration
value and the whole chain built on it is illustrative only.
Example — reading a Modbus TCP capture taken during an intermittent-dropout investigation:
$ cst modbus-decode capture.pcap --exceptions --unanswered
frames : 13 (7 req / 6 resp)
unit ids : 1
capture span : 0.600 s
Read Holding Registers 13
response time : mean 8.33 ms, max 10.00 ms
exceptions : 1
unanswered : 1
exception responses:
t=1000.510000 unit=1 txn=6 Read Holding Registers: Illegal Data Address
unanswered requests: 1
t=1000.600000 unit=1 txn=7 Read Holding Registers start=200 qty=2
--addresses lists the register spans the client actually polls, which you can
diff against the design-time map from cst modbus-map.
Example — checking a digital-twin proposal before a gate would see it, and the synchronization health of the telemetry feeding it:
$ cst twin-validate payload.json --register methods.yml --method-id digital_twin_state_sync
3 problem(s):
- missing required contract field "calibration_version" — which calibration the value rests on
- requested_authority 3 exceeds the register ceiling 2 for this method
- payload is stale: valid_until 1752960302.000 passed at 1752960500.000 (198 s late) — a gate must reject it
$ cst twin-sync telemetry.csv --max-age 5
Twin synchronization health: 60 samples over 70 s
median interval: 1 s
max gap: 12 s (1 gap(s) detected)
out-of-order samples: 0
stale samples: 0 (0.0%)
mean skew: 0.1922 s (max |skew| 0.204 s)
skew drift: 0.000309 s/s
Warnings:
! 1 telemetry gap(s); longest 12 s at 1752960030.000 — twin state was unsynchronized across it
The authority ceiling comes from the AI method register, never from the payload’s own claim. See The Digital Twin for the contract and the maturity ladder these checks implement.
Limits
- Screening and design-assist calculations — final designs need the official standards, project-specific data, and engineering review.
cst twin-validateandcst twin-syncreport and never act. A clean result means a proposal is well-formed enough for a non-learned gate to judge, or that telemetry has the synchronization properties it claims — never that anything is safe or authorized. The gate that clamps or vetoes a proposal is plant-side engineering with its own integrity requirements, not a Python library.cst modbus-decodereads capture files offline and never opens a network interface. Taking the capture is a separate step: on a live OT segment use a passive method (a TAP or a switch mirror port) — active scanning or injected traffic can disturb a process that is controlling plant.- Sample table data is for demonstration; transcribe licensed values before design use (the tool warns you until you do).
- Live PLC helpers (
pycomm3extra) read and verify only — they never write to a running controller.
See the templates page for documents generated by the toolkit that you can download directly.
This site is an independent educational reference for industrial automation standards. It paraphrases and organizes guidance in original language; it is not a substitute for the official published standards, professional engineering judgment, or legal review, and content has not been independently verified against current published editions.
Items marked Review pending await technical review against the identified edition. Items marked Planned have no reviewed source material behind them. Do not rely on this site for compliance determinations, safety-critical design decisions, or legal interpretation.