multisim2kicad 0.0.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Cameron Tacklind <cameron@tacklind.com>
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,228 @@
1
1
  # multisim2kicad
2
2
 
3
- Placeholder that claims the name. Install a real release (0.1.0 or later); see https://github.com/cinderblock/multisim2kicad
3
+ Convert NI Electronics Workbench designs — **Multisim** schematics (`.ms14`,
4
+ `.ms13`, …) and **Ultiboard** PCBs (`.ewprj`) — to modern **KiCad**
5
+ (`.kicad_sch`, `.kicad_pcb`, `.kicad_pro`).
6
+
7
+ Reading the proprietary containers is done by
8
+ [`electronics-workbench-decoder`](https://www.npmjs.com/package/electronics-workbench-decoder)
9
+ (`ewd`); this tool turns what's in them into KiCad.
10
+
11
+ > Work in progress. See [`plans/converter.md`](plans/converter.md) for the
12
+ > roadmap, what is and isn't translated yet, and every format finding so far.
13
+
14
+ ## Usage
15
+
16
+ Needs Node 20+ (or [Bun](https://bun.sh)).
17
+
18
+ ```bash
19
+ npx multisim2kicad path/to/Design.ms14 path/to/Design.ewprj # writes ./out/
20
+ npx multisim2kicad -o converted/ path/to/project-folder/ # every design in a folder
21
+ npx multisim2kicad -o libs/ "path/to/Stocked Components.prj" # an EW component database
22
+ ```
23
+
24
+ As a library, `import { convertProject, convertDatabase, parsePcbXml, ... } from "multisim2kicad"`
25
+ gives the converters, the parsers into a format-neutral IR, and the KiCad emitters.
26
+
27
+ ### From a checkout
28
+
29
+ ```bash
30
+ bun install
31
+ bun run dev -o out/ path/to/Design.ms14 # same arguments as the CLI
32
+ bun test && bun run typecheck
33
+ bun run build # dist/ (what npm ships)
34
+ ```
35
+
36
+ Releases are published to npm by CI (`.github/workflows/publish.yml`) when a
37
+ `v<version>` tag matching `package.json` is pushed.
38
+
39
+ Inputs can be the binary EW files or XML already decoded by `ewd`; the
40
+ design type comes from the file's contents, not its extension. A schematic
41
+ and a board with the same name in the same folder (`Main.ms14` +
42
+ `Main.ewprj`) become **one linked KiCad project**.
43
+
44
+ Output per project `<name>`:
45
+
46
+ - `<name>.kicad_pro`, with the board's design rules: Ultiboard's default
47
+ clearance, track width and via as KiCad's Default net class, nets with
48
+ their own clearance or width as further net classes, and the minimum
49
+ track width / board-edge clearance (plus `<name>.kicad_dru` when a board
50
+ sets separate clearances to pads or vias)
51
+ - `<name>.kicad_sch` (+ one file per sub-sheet / extra page) from the `.ms1x`
52
+ - `<name>.kicad_pcb` from the `.ewprj`
53
+ - `<name>.pretty/`: the board's footprints as a project library (one
54
+ `.kicad_mod` per EW footprint, unrotated and top-side), registered in
55
+ `fp-lib-table`
56
+ - `<name>.kicad_sym`: the schematic's symbols as a project library (one
57
+ symbol per part, named after the part in the EW database, multi-section
58
+ parts as multi-unit symbols), registered in `sym-lib-table`
59
+
60
+ When both halves are present they are linked the way KiCad expects:
61
+ footprints carry their symbol's sheet path, symbols name their footprint,
62
+ footprint values follow the schematic, and parts that exist only on the
63
+ board (mounting hardware, fiducials) are marked board-only.
64
+
65
+ ## What gets translated
66
+
67
+ PCB: board outline, the full copper stack (inner layers from the
68
+ lamination settings), copper tracks, every pad kind (round, square,
69
+ rectangle, rounded, custom shapes; SMD on the right side), vias, mounting
70
+ holes, footprints that keep each part's rotation and side (top or
71
+ bottom) with the part's own silkscreen/fab/courtyard drawings and its
72
+ reference and value text as placed in Ultiboard, power planes and copper areas as KiCad zones (net, clearance, thermal
73
+ and island settings), nets (pads, tracks and vias carry their nets),
74
+ silkscreen/mask/fab/courtyard graphics including arcs, board text, rule
75
+ areas, and 3D/mechanical/custom EW layers as named KiCad user layers.
76
+
77
+ Schematic: every page and hierarchical block as a KiCad sheet hierarchy,
78
+ parts with their real body graphics and Multisim's final reference
79
+ designators (multi-section parts as KiCad units), pins at the exact positions
80
+ Multisim wires attach to, orientation (rotation/mirror), wires, junctions,
81
+ power and ground ports, global/local/hierarchical net connectors, user net
82
+ names, buses (with bus entries; buses continued across pages), free text.
83
+ Shared supply pins of multi-section parts (an op-amp's V+/V- on every
84
+ section) stay connected the way Multisim wires them. One schematic unit maps to 10 mil so everything sits on a
85
+ KiCad grid.
86
+
87
+ Simulation: the converted schematic runs in KiCad's simulator (ngspice).
88
+ Each part's SPICE model from the design goes into `<design>.lib` next to
89
+ the schematic. The part points at it through KiCad's `Sim.*` fields, which
90
+ map its pins to the model's nodes in Multisim's order.
91
+
92
+ - Resistors, capacitors and inductors use KiCad's built-in models.
93
+ - Sources, diode models and other one-off cases get a small wrapper
94
+ subcircuit holding exactly the lines Multisim would netlist.
95
+ - KiCad leaves power symbols out of simulation, but Multisim's VCC / VDD
96
+ symbols are real sources. Each supply net therefore gets a
97
+ simulation-only source symbol (`SUP1`, ...; not in the BOM, not on the
98
+ board), parked to the right of the root sheet.
99
+ - Parts Multisim has no model for (most ICs and connectors) are marked
100
+ "exclude from simulation".
101
+ - A few Multisim-only SPICE constructs are rewritten for ngspice:
102
+ `.mergenodes`, `TABLE ... USELIM`, and the interactive potentiometer
103
+ (fixed at its saved setting).
104
+ - PSpice forms ngspice lacks are translated: `sdt()` (integral) becomes an
105
+ XSPICE integrator, `E`/`G ... LAPLACE {in} {H(s)}` an XSPICE `s_xfer`
106
+ block (plus a delay line for an `e^(-sT)` factor; numeric coefficients
107
+ only), and subcircuit parameters named like functions (`max`, `min`) are
108
+ renamed. A `FREQ` response-table source has no exact equivalent: its part
109
+ is excluded, with a warning.
110
+ - Digital parts simulate with ngspice's XSPICE gates. Each digital pin
111
+ gets the ideal analog/digital bridge from its Multisim interface model.
112
+ - Multisim's `d_chip` behavioural logic (most 74xx and 4000-series MSI
113
+ parts: counters, decoders, comparators, registers, latches, multiplexers)
114
+ is compiled into an XSPICE subcircuit. Each table output becomes a
115
+ `d_lut` truth table, and each state flag a `d_dff` with its clocked and
116
+ asynchronous rows. The 74LS161, 74LS74, 74LS85, 74LS138, 74LS47, 74150,
117
+ 4511 and 40192 were checked against their datasheets in ngspice. Timing is
118
+ simplified: each output gets its slowest listed delay, and setup / hold
119
+ checks are dropped.
120
+ - Circuit parameters become a `.param` simulator directive on their sheet.
121
+ Part values that use them stay expressions.
122
+ - A part's expression can read another part's current (`I(Vsensor1)`) or a
123
+ net by name (`V(pri)`), as in Multisim's flat netlist. The part that owns
124
+ the current or sits on the net gets a probe: a behavioural source copying
125
+ the value onto a shared (`.global`) node, which the expression reads.
126
+ Coupled inductors that are separate parts (`K1 L4 L5 0.9`) become a `K`
127
+ line in a text directive on the root sheet.
128
+ - Tri-state and bidirectional pins (bus buffers and transceivers: 74xx125,
129
+ 240, 244, 245, 373, ...) work on shared buses. Each output that can go
130
+ high-Z gets an enable signal from the chip's tables, and the enable drives
131
+ the pin's output switch. Multisim's own high-Z sensing (`dac_hiz`) has no
132
+ ngspice equivalent.
133
+ - Parts whose model needs something ngspice doesn't have are excluded,
134
+ with a warning: `chirp()` sources, `d_vhdl`, other Multisim-only code
135
+ models, PSpice `FREQ` tables.
136
+ - A digital input left unconnected reads low, as in XSPICE (some of NI's
137
+ counter demos leave `~LOAD` open, so they load instead of counting).
138
+ - Schmitt-trigger inputs (74xx14 and friends) keep their hysteresis: an
139
+ XSPICE `hyst` block ahead of the input bridge. Multisim's interactive
140
+ digital constant is a fixed logic level at its saved state. Ideal digital
141
+ outputs have a 1 mOhm series resistance, so an output tied to a source or
142
+ to another output still solves.
143
+ - Vendor models' capacitor `IC=` values seed the operating point
144
+ (`.nodeset`), as PSpice uses them; PWM controller latches need that.
145
+
146
+ - The design's simulation settings come along as a text directive on the
147
+ root sheet: Multisim's SPICE options (its default `rshunt=1e12`, which
148
+ lets designs with floating nets simulate, and any tolerances the designer
149
+ set) and the analysis Multisim has results for (transient, else Fourier,
150
+ else AC, else operating point), so KiCad's Run does what Multisim did. A
151
+ Fourier analysis comes across as its transient plus a note with the
152
+ fundamental. Other analyses it ran (noise, sweeps, ...) are listed in a
153
+ comment.
154
+ - A design driven by LabVIEW co-simulation gets a warning: those inputs
155
+ are undriven in KiCad.
156
+
157
+ Checked on NI's own Multisim 13 sample circuits: none fail to parse, and
158
+ 156 carry an analysis Multisim ran; 145 of those run to completion in
159
+ KiCad's ngspice as converted. Of the other 11:
160
+ - 2 are meant to fail: NI's "Overcoming Simulation Challenges" demos, whose
161
+ notes say to watch the convergence failure.
162
+ - 3 are LabVIEW co-simulations, driven by a LabVIEW VI that isn't in the
163
+ design.
164
+ - 1 saves a 5000-second transient at a 0.1 ms step.
165
+ - 5 are switching converters on which ngspice's transient gives up
166
+ ("timestep too small") where Multisim's solver does not.
167
+
168
+ 192 of the 200 solve their operating point. The rest are converters whose
169
+ own analysis skips it, and one co-simulation.
170
+
171
+ The project's simulator compatibility is set to PSpice, because Multisim's
172
+ vendor models use PSpice syntax (`IF()`, `R ... TC a b`).
173
+
174
+ A board whose ICs have no model leaves those nets floating; Multisim's
175
+ `rshunt` option (carried over) usually lets it simulate anyway. A large
176
+ digital board may still need models for its ICs.
177
+
178
+ An EW component database becomes KiCad libraries named after it. That is
179
+ a Multisim database project (`.prj` / `.usr`), or NI's master database
180
+ `MSCOMP_S.PRD` that Multisim installs under
181
+ `C:\ProgramData\National Instruments\Circuit Design Suite\<version>\database\`
182
+ (about 57,000 parts and 7,000 footprints; around two minutes). Convert
183
+ NI's database for your own use only: it is NI's content, so don't
184
+ redistribute the output.
185
+
186
+ - `<name>.pretty/`: every Ultiboard footprint stored in it
187
+ - `<name>.kicad_sym`: every component, drawn from its Multisim symbol
188
+ (sections as units, pin numbers from its package, pin electrical types,
189
+ reference prefix from its family; pins Multisim hides, like a logic
190
+ chip's GND / VCC, on an extra power unit), with its Footprint pointing into
191
+ `<name>.pretty` when the database holds the package (otherwise the
192
+ package name is kept as an `EW_Package` field)
193
+ - `<name>.spice/<family>.lib`: the SPICE models of the database's
194
+ simulated parts, one file per family. Each symbol's `Sim.*` fields point
195
+ into it through `${KIPRJMOD}`. That works when the libraries sit in the
196
+ project folder; if you install them globally, fix the path. A part
197
+ with several sections (a quad op-amp) is one subcircuit across all its
198
+ units. Parts without a model, and the few whose template needs values
199
+ Multisim only sets on a placed part, are excluded from simulation. Set
200
+ the project's simulator compatibility to PSpice (Simulator > Settings).
201
+
202
+ The symbol and footprint libraries are registered in the project's lib
203
+ tables.
204
+ `plans/converter.md` tracks these.
205
+
206
+ ## Checking results
207
+
208
+ ```bash
209
+ bun run test # unit + sample-design tests
210
+ bun run typecheck
211
+ bun run corpus # convert a whole corpus and score it (see below)
212
+ ```
213
+
214
+ `bun run corpus` converts every design under `corpus/` (gitignored — put your
215
+ own designs there), checks each output with `kicad-cli` (ERC/DRC, netlist
216
+ export), and scores it against EW's own data: the schematic's KiCad netlist
217
+ vs Multisim's netlist, and the share of PCB net pins that landed on a pad.
218
+ Report: `out/corpus/report.md`.
219
+
220
+ `bun run scripts/parity.ts <output-folder>` checks converted projects that
221
+ have both a schematic and a board: the schematic's KiCad netlist against the
222
+ board's pad nets, compared as connectivity (net names aside), plus which
223
+ footprints are linked, board-only or orphaned.
224
+
225
+ `kicad-cli` is always run through `scripts/run-hidden.ps1`, which starts it
226
+ on a private Windows desktop so no KiCad window or warning dialog can appear
227
+ on screen; any dialog it raises is logged and closed. Set `KICAD_CLI` to
228
+ point at a different `kicad-cli.exe` (default: KiCad 10).